Tag: ios5

Objective-Cstring(yyyy-mm-dd)到NSDate

我的应用程序是一个JSON代码,涉及stringtypes的date。 (如“2011-10-01”)。 我想知道如何将它转换成NSDate? 它需要以不同的时间格式显示,如“2011年10月1日”。 恩。 这段代码不起作用: NSString *date1 = @"2010-11-12"; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"yyyy-MMMM-dd"]; NSDate *date2 = [dateFormat dateFromString:date1]; NSString *strdate = [dateFormat stringFromDate:date2];

Obj-C:__blockvariables

是否有可能分配一个局部variables的范围是在一个块以外的值,并保留它的值? 特别是,我编码的iOS和我有一个嵌套块内的另一个块,我想分配一个NSString值块内的价值和稍后(块外)使用它。 我试图使用__block螺母时,我指的是NSString块后,我得到一个不良的访问错误。 我正在使用ARC是重要的。 例如: __block NSString *str; someBlock ^(id param1) { str = @"iPhone"; } [str getCharAtIndex:1]; //or w/e 我在做一些概念上的错误或不允许或者什么? 非常感谢帮助。 编辑: 这里是实际的代码,基本上代码得到的鸣叫作为一个JSON对象,然后我要做的就是显示文本。 在代码中,我没有从json中提取文本,我试图做一个概念certificate – (IBAction)getTweet:(id)sender { __block NSString *displayStr; //account instance ACAccountStore *store = [[ACAccountStore alloc] init]; ACAccountType *twitterAcountType = [store accountTypeWithAccountTypeIdentifier: ACAccountTypeIdentifierTwitter]; //request access [store requestAccessToAccountsWithType: twitterAcountType withCompletionHandler: ^(BOOL granted, NSError *error) […]

没有findios类“预期types”

我在FooterSelectorView.h遇到了两个问题,我不知道为什么。 一个是警告,另一个是错误。 出于某种原因xcode不能识别FooterArchiveItemView所以我不能input我的对象,因为这是导致其他propblems。 有没有人见过这样的事情? 我该如何解决? FooterSelectorView.h #import <UIKit/UIKit.h> #import "FooterArchiveItemView.h" @interface FooterSelectorView : UIImageView // #warning Type of property 'activeItem' does not match type of accessor 'setActiveItem:' @property (nonatomic, retain) FooterArchiveItemView *activeItem; // #error Expected a type – (void)setActiveItem:(FooterArchiveItemView *)activeItem_; – (void)update; – (CGPoint)absoluteCenterOf:(UIView *)obj; @end 相关类 FooterArchiveItemView.h #import <UIKit/UIKit.h> #import "AutosizeableView.h" #import "FooterArchiveView.h" typedef […]

EKAlarm不会在iOS 5中设置

我写了下面的代码创build一个事件。 设置闹钟在iOS 4中工作正常,但在iOS 5中没有设置。 这是一个错误还是我错过了什么? EKCalendar *cal = [self.eventStore defaultCalendarForNewEvents]; EKEvent *event = [EKEvent eventWithEventStore:self.eventStore]; event.calendar = cal; // ……. EKAlarm *alarm = [EKAlarm alarmWithRelativeOffset:-3600]; event.alarms = [NSArray arrayWithObject:alarm]; // …….

改变UIStepper的外观

UIStepper是非常方便的,但我想改变它的外观,我需要定制的图标不是加号和减号,我也想改变控制的颜色。 我怎样才能做到这一点? 提前致谢!

我可以更改我的iOS部署目标到5.0在xcode 4.5?

我开发的iPhone应用程序使用base SDKs 6.0和deployment target为6.0 现在我想将我的deployment target更改为5.0而不是6.0 有可能改变吗? 我在xcode 4.5中使用了自动布局function 和 我有一个疑问:我听说,如果我开发的应用程序使用iOS 5的部署目标和iPhone 5的Default-568h@2x.png启动图像Default-568h@2x.png苹果将​​拒绝我的应用程序..( 原因:无效启动图像 – 你的应用程序包含一个尺寸修改器的启动图像,仅适用于使用iOS 6.0 SDK或更高版本构build的应用程序 ),但为了支持iPhone 5,我必须提供图像Default-568h@2x.png图像。 如何解决这个问题呢 ? 感谢您阅读问题。

为什么在viewDidLoad中不执行SegueWithIdentifier工作?

一旦viewDidLoad在视图控制器上被调用,我试图触发一个故事板segue。 segue附加了一个标识符,并且在从一个链接到button或其他控件的方法中调用时工作正常。 但是它在viewDidLoad里面不起作用。 它只是默默地失败。 在viewDidLoad中有没有关于segue被忽略的规则? 我已经试过这两个: [self performSegueWithIdentifier: @"mySegue" sender: self]; 和这个: [self dismissViewControllerAnimated:YES completion:^() { [self performSegueWithIdentifier:@"mySegue" sender:self]; }]; 既没有工作。

iOS推送通知的可用声音列表

我试图改变我的推送通知的声音,但我不知道名称是什么使用。 我想要使​​用“电子”声音,但是我在有效载荷中的声场中放置了什么? 有没有可用的声音列表?

iOS:如何正确获取电池电量

我试图得到正确的电池电量。 但是这个值不像iphone的状态栏中的值。 通过代码使用UIDevice: [[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; [[UIDevice currentDevice] batteryLevel]; 请有人帮我! 我需要得到正确的电池级别,就像在状态栏imdimatery。

以编程方式中心UIButton

我有一个UIButton,我以编程方式添加。 这里没有问题,它应该像它应该和看起来不错。 然而,当我倾斜手机风景的button不正确,我希望它仍然居中。 肖像: 景观: 我已经尝试了一堆东西,但似乎无法得到它的工作,在我看来,autoresizing应该照顾它,但是…它不起作用的情况下。 – (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 49)]; _notMeButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *butImage = [[UIImage imageNamed:@"notme.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:6]; UIImage *butImagePressed = [[UIImage imageNamed:@"KC_notmePressed.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:6]; [_notMeButton setBackgroundImage:butImage forState:UIControlStateNormal]; [_notMeButton setBackgroundImage:butImagePressed forState:UIControlStateHighlighted]; [_notMeButton setTitle:NSLocalizedString(@"Change address", @"KlarnaCheckout") forState:UIControlStateNormal]; [_notMeButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal]; [_notMeButton setTitleColor:[UIColor […]