cocoa-touch

Hide UISearchBar Cancel Button

社会主义新天地 提交于 2019-12-29 18:49:09
问题 I have a UISearchDisplayController and UISearchBar hooked up to my ViewController via Outlets from my nib. I'd like to hide the cancel button so that the user never sees it. The problem is that the following code hides the button, but only after displaying it to the user for a millisecond (e.g., it flashes on the simulator and device and then disappears out of view). - (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller { controller.searchBar.showsCancelButton

Drawing a moving sine wave anti-aliased

夙愿已清 提交于 2019-12-29 15:02:12
问题 I want to draw a moving sine wave with variable frequency and variable amplitude in a crisp and anti-aliased way. How is this possible? 回答1: Well, I implemented sine wave into the UIView drawrect method as follows : float x=75; float yc=50; float w=0; while (w<=rect.frame.size.width) { CGPathMoveToPoint(path, nil, w,y/2); CGPathAddQuadCurveToPoint(path, nil, w+x/4, -yc,w+ x/2, y/2); CGPathMoveToPoint(path, nil, w+x/2,y/2); CGPathAddQuadCurveToPoint(path, nil, w+3*x/4, y+yc, w+x, y/2);

Showing/hiding navigation bar with smooth animation

白昼怎懂夜的黑 提交于 2019-12-29 10:36:30
问题 I have a navigation based app. The first view (rootcontroller) starts with three large buttons only. No navigationbar. From there, everything else is tableviews and have navigation bars. I'm doing this to show/hide the navigation bar: MyAppAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate]; appDelegate.navigationController.navigationBar.hidden = NO; Once I leave the root controller, the navigation bar will jerk into place and lay on top of the tableview, rather than

UIWebView resizes text after rotating: looking for explanation for magical bug or my stupidity

两盒软妹~` 提交于 2019-12-29 10:27:16
问题 so I have UIWebView in my application and I load some html (article) to it, put some CSS to make everything nicer. That's simple and clear and everything is perfect until I try to add reading in landscape functionality and then I've noticed that UIWebView ignores any css "font-size" I've put in HTML and increases font size drastically after rotating to landscape mode. I've spent about 4-5 hours (I'm new to programming Iphone application, but I'm quite stubborn when it comes to making

How to initiate UIProgressView to a certain value?

为君一笑 提交于 2019-12-29 09:38:07
问题 Would it be in the .h or .m and how do I do this? 回答1: it would definitely be in the .m file. Initialize your UIProgressView, and then call setProgress: on it. 回答2: As defined in the UIProgressView documentation, UIProgressView has a progress property. Just set that when you create your view: UIProgressView *view = [[UIProgressView alloc] initWithProgressViewStyle:whateverStyle]; view.progress = 0.75f; // Do whatever you want with the view // (and don't forget to -release it later) would

Combined framework simulator/device binary Xcode 7.3

為{幸葍}努か 提交于 2019-12-29 09:20:10
问题 I followed carefully THIS POST for this In summary you have to use lipo to connect each device and simulator build Using: lipo -create -output "MyFrameworkName" "Debug-iphonesimulator/MyFrameworkName.framework/MyFrameworkName" "Debug-iphoneos/MyFrameworkName.framework/MyFrameworkName" I am choosing any framework Debug-iphonesimulator or Debug-iphoneos as a base to add the file that resulted from lipo. Example: The problem is that no matter which of the 2 use as a base ( Debug-iphonesimulator

How can I move to another view controller when the user clicks on a row?

一世执手 提交于 2019-12-29 09:11:11
问题 I am new to iPhone development, and I want to move to another page when the user clicks on a particular row. So, if they click on first row, I want the page to redirect to the first view controller, and so on. Each row has its own view controller. 回答1: first of all you don't need to set different view controller for each row (unless you have a very good reason for doing that). the correct way is to set 1 view controller that will fit all the cells in the raws and change its data according to

NSUserDefaults not working right

我们两清 提交于 2019-12-29 08:51:40
问题 Having some trouble with NSUserDefaults here. Here's how I'm creating it: NSString *theCity = @"Test City"; [[NSUserDefaults standardUserDefaults] setObject:theCity forKey:@"SavedCity"]; Here's how I'm trying to retrieve it: if ([[NSUserDefaults standardUserDefaults] objectForKey:@"SavedCity"]) { NSLog(@"Key exists! %@",[[NSUserDefaults standardUserDefaults] objectForKey:@"SavedCity"]); } else { NSLog(@"No city saved!"); } The problem I have is that even if there IS a key for "SavedCity" (I

Swift if let evaluates successfully on Optional(nil)

社会主义新天地 提交于 2019-12-29 08:42:09
问题 I have a custom object called Field. I basically use it to define a single field in a form. class Field { var name: String var value: Any? // initializers here... } When the user submits the form, I validate each of the Field objects to make sure they contain valid values. Some fields aren't required so I sometimes deliberately set nil to the value property like this: field.value = nil This seems to pose a problem when I use an if-let to determine whether a field is nil or not. if let value =

iOS: how to stop text animation in partial curl

半腔热情 提交于 2019-12-29 08:41:53
问题 I'm using a partial curl modal in my iOS application. Please see this video: http://vimeo.com/38643030 During the partial curl transition, the text in the round rect buttons is moving too. How can I stop this? 回答1: Put [self.view layoutIfNeeded] in the -viewDidLoad implementation for the view controller that's being shown via the curl animation. This makes the buttons & their contents lay out once before the animation starts instead of trying to do its layout (and redo it as things change