cocoa-touch

Customize UISlider (track image height)

99封情书 提交于 2020-01-09 10:39:27
问题 I'm customizing a UISlider . I could set a custom thumb image that is higher than the usual thumb however I could not make the track higher when setting a higher minimum track image but the track height remained the same. It should be possible as in the iPod/Music App on the iPad the volume slider is also higher as the usual slider as you can see here: (source: cocoia.com) 回答1: You need to subclass the slider and override the trackRectForBounds: method, like this: - (CGRect)trackRectForBounds

Dismissing UIPickerView with Done button on UIToolBar

大城市里の小女人 提交于 2020-01-09 10:29:12
问题 I am just trying out which is better with regards to dismissing a UIPickerView -- a button on the navigation bar or a "Done" button on a toolbar above the picker view. I have implemented both buttons, and I am trying to dismiss the picker view and resign first responder. How can I dismiss the UIPickerView with the "Done" Button on the toolbar? This is my code for the UIToolBar : UIToolbar* keyboardDoneButtonView = [[UIToolbar alloc] init]; keyboardDoneButtonView.barStyle = UIBarStyleBlack;

Implementing pull to refresh view feature

倾然丶 夕夏残阳落幕 提交于 2020-01-09 10:00:09
问题 Can we implement pull to refresh feature on a custom view controller?. My view controller is not a table view controller and I want to refresh this view on pulling the screen down. How can I implement this feature? 回答1: In short, you need to do the following: Embed your view in a UIScrollView . Set your controller as the delegate of the scroll view. Add a "Pull To Refresh" subview to the scroll view such that its frame is off the top of the screen. Something like CGRectMake(0, -30, 320, 30)

iPhone SDK 4 “Half curl page transition”

梦想与她 提交于 2020-01-09 09:04:54
问题 In Steve Jobs' keynote announcement of the iPhone SDK 4 earlier this year, one of the slides showed that a "Half curl page transition" was part of the new SDK: alt text http://cl.ly/c203189b44788d490ae8/content I've looked through the iOS API docs and I can't seem to find this transition. Does anyone know where it is? 回答1: It's not a transition, but a modalTransitionStyle . You can check the docs here: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController

iPhone SDK 4 “Half curl page transition”

[亡魂溺海] 提交于 2020-01-09 09:04:06
问题 In Steve Jobs' keynote announcement of the iPhone SDK 4 earlier this year, one of the slides showed that a "Half curl page transition" was part of the new SDK: alt text http://cl.ly/c203189b44788d490ae8/content I've looked through the iOS API docs and I can't seem to find this transition. Does anyone know where it is? 回答1: It's not a transition, but a modalTransitionStyle . You can check the docs here: http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController

iPhone UITableViewCell layer shadow

南楼画角 提交于 2020-01-09 08:41:06
问题 I'm trying to add a shadow to a UITableViewCell using the layer.shadowColor, Offset, Radius but it doesn't seem to affect it in any way. The table is grouped style. Any ideas why? Here is the code i'm using: cell.layer.shadowColor= [UIColor blackColor].CGColor; cell.layer.shadowRadius = 5.0; cell.layer.shadowOffset = CGSizeMake(10, 10); 回答1: You need to also set the shadow opacity, it defaults to 0 and you won't see anything if you don't explicitly set it. CALayer Reference cell.layer

Convert int to shortened, formatted string

一笑奈何 提交于 2020-01-09 07:38:32
问题 The user will enter a dollar value as an int , and I'd like to convert the result into a shortened, formatted string. So if the user enters 1700, the string would say "$1.7k". If the user enters 32600000, the string would say "$32.6m". Update Here's the code I have so far. It seems to be working for numbers ~10k. I would just add more if statements for bigger numbers. But is there a more efficient way to do this? NSNumberFormatter *nformat = [[NSNumberFormatter alloc] init]; [nformat

Convert int to shortened, formatted string

故事扮演 提交于 2020-01-09 07:38:24
问题 The user will enter a dollar value as an int , and I'd like to convert the result into a shortened, formatted string. So if the user enters 1700, the string would say "$1.7k". If the user enters 32600000, the string would say "$32.6m". Update Here's the code I have so far. It seems to be working for numbers ~10k. I would just add more if statements for bigger numbers. But is there a more efficient way to do this? NSNumberFormatter *nformat = [[NSNumberFormatter alloc] init]; [nformat

Reverse Geocode Current Location

孤者浪人 提交于 2020-01-09 07:38:11
问题 Is it possible to reverse Geocode your current location on SDK 3.x? I need to simply get the zip code of the current location. The only examples I've seen use CoreLocation which I dont think was introduced until SDK 4. 回答1: You can use MKReverseGeocoder from 3.0 through 5.0. Since 5.0 MKReverseGeocoder is depreciated and usage of CLGeocoder is advised. You should use CLGeocoder if available. In order to be able to extract address information you would have to include Address Book framework.

Having app restart itself when it detects change to privacy settings

烂漫一生 提交于 2020-01-09 07:24:10
问题 I have an app that uses the ALAssets framework to access to the users photo library. I wrote some code that detects whether or not the app has permission to access the photo library, and if it doesn't, I display an alert message which tells the user to turn on location services for the app in settings. Problem is, when the user manually changes the privacy settings and then they reopen the app, iOS forces the app to crash with SIGKILL. I've noticed that the way another app handles this is by