cocoa-touch

Adjusting interface when keyboard appears for UITextField or UITextView

不问归期 提交于 2020-01-12 03:49:07
问题 I have a table with each cell containing a label and a text field. Problem is that when i go to edit the last row, keyboard hides the lower portion of the table, and i can't see what is being typed. How can i move my interface above the keyboard so i see what is being typed? Thanks, Mustafa 回答1: You'll want to register your viewController for UIKeyboardDidShowNotification and UIKeyboardWillHideNotification events. When you get these, you should adjust the bounds of your table; the keyboard is

Creating multiple NSURLConnections. How to identify which Async call

点点圈 提交于 2020-01-12 03:30:54
问题 I am intending to create 2 requests using NSURLConnection. When the server responds and calls connectionDidFinishLoading it passes in the connection as the parameter, but how do I identify which connection is passed in? 回答1: Save both NSURLConnection objects as member variables of whatever delegate object you passed to connectionWithRequest:delegate:. Then you can just compare each of those to the NSURLConnection passed to connectionDidFinishLoading:, and respond appropriately: - (void

Choosing between the two - Interface Builder OR creating via code

旧时模样 提交于 2020-01-12 02:34:13
问题 When I started with IPhone development I preferred using Interface builder for creating views in my application. With time I considered the option of creating the application via code which I really feel comfortable working with. Now, when I know both ways to create my user interface, I have doubts which way to follow. I keep thinking where to use IB and where to use code . How can I figure out before starting with my application, which way should I create my UI ? 回答1: There are a number of

Gesture recognition with UIWebView

十年热恋 提交于 2020-01-12 02:18:08
问题 I have set up some gesture recognition in an app that I'm building. One of the gestures is a single finger single tap, which hides the toolbar at the top of the screen. Works great except for one thing: a tap on a link causes the toolbar to go away, too. Is it possible to detect a tap that was not a tap on a link? Could I do this by seeing where the tap occurred, and only take action if it didn't occur on an html link? Is this is possible, a pointer to how to determine if a link was tapped

Animate UIButton's title change

ぃ、小莉子 提交于 2020-01-11 20:09:39
问题 Here I found how to animate UIButton 's title change using now-deprecated beginAnimations:context: method: UIBUtton title animation for iPhone How to do the same thing using current APIs? Update: I've tried to use block-based animations: NSTimeInterval animationDuration = animated ? 1.f : 0.f; [UIView animateWithDuration:animationDuration delay:0.f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{ [button setTitle:newTitle forState

Animate UIButton's title change

 ̄綄美尐妖づ 提交于 2020-01-11 20:09:30
问题 Here I found how to animate UIButton 's title change using now-deprecated beginAnimations:context: method: UIBUtton title animation for iPhone How to do the same thing using current APIs? Update: I've tried to use block-based animations: NSTimeInterval animationDuration = animated ? 1.f : 0.f; [UIView animateWithDuration:animationDuration delay:0.f options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction animations:^{ [button setTitle:newTitle forState

How to recreate the UITabBarItem image filter?

十年热恋 提交于 2020-01-11 19:57:22
问题 I'm writing a custom UITabBar replacement, and I would like to know how to recreate the filter that the built-in implementation does with the UITabBarItem image - that blue shining on selected tabs and gray gradient on unselected ones. I guess it's a matter of using the source image alpha value as a mask and overlay it with a pre-made blue (or whatever color) shining image and another one grayed out, but I would like to know what is the best approach from a code point of view. Best, 回答1: Edit

Passing a ManagedObjectContext to a second view

自古美人都是妖i 提交于 2020-01-11 19:40:06
问题 I'm writing my first iPhone/Cocoa app. It has two table views inside a navigation view. When you touch a row in the first table view, you are taken to the second table view. I would like the second view to display records from the CoreData entities related to the row you touched in the first view. I have the CoreData data showing up fine in the first table view. You can touch a row and go to the second table view. I'm able to pass info from the selected object from the first to the second

adding a UITableView programmatically to a UIViewController

[亡魂溺海] 提交于 2020-01-11 18:51:50
问题 I'm loading a UIViewController into one of my Nav controller's hierarchies, which will contain some text and some images. At the bottom, I will want to create a expandable and collapsable tableview. First off, is this idea possible? If it is, how do I add it and where do I place the data source and delegate methods? Can I just make a separate subclass of the TableViewController and then add it to my ViewController as a subview? 回答1: Yes, you can create a UITableView whose delegate, datasource

convertPoint:toView: in landscape mode giving wrong values

核能气质少年 提交于 2020-01-11 17:10:28
问题 I have a view which is created in landscape mode (long after rotation etc.). In this view, I want to find a point relative to the main window. The following code works in portrait mode, but in landscappe it still returns values as if it were in portrait. CGPoint ptRelativeToWindow = [self convertPoint:self.bounds.origin toView:nil]; Solved This solved the problem and gives the right coordinates: [self convertPoint:self.bounds.origin toView:[UIApplication sharedApplication].keyWindow