Tag: cocoa touch

确定使用哪个共享扩展

由于UIActivityViewController上的completionHandler在iOS 8中已被弃用,是否有任何方法可以确定用户使用哪个共享扩展/活动?

NSJSONSerialization – 无法将数据转换为string

我遇到了从Met Office Datapoint API读取JSON的NSJSONSerialization问题。 我得到以下错误 Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn't be completed. (Cocoa error 3840.)" (Unable to convert data to string around character 58208. 我已经检查并认为这是根据字符位置的违规行 {"id":"353556","latitude":"57.1893","longitude":"-5.0929","name":"Sóil Chaorainn"} 根据我尝试过的几个validation器,JSON本身似乎是有效的,我也希望它也来自Met Office这样的大型组织。 NSJSONSerialization不应该与'ó'这样的字符一起工作吗? 如果不是我怎么去改变编码types来处理这个? 提前谢谢了

Cocoa Touch是否有search树数据结构?

我一直在Google上查看这些内容,并阅读SDK文档中的Collections条目,并且什么都没有发现。 iOS SDK是否提供了BST(任何变体)实现? 在一个主要的开发平台上丢失这么基本的东西似乎很奇怪。 他们的哈希实现是不是神奇? 或者开发者认为没有人会对有订单的东西进行插入/删除? 我现在可以使用NSSet ,因为我知道我们大多数人(包括我自己)并不是真的在iOS上编写任何需要确保访问时间的计算任务,但它仍然在啃我。

使用reverseGeocodeLocation设置地址string:并从方法返回

我尝试本地化一个地址string的开始和结束点,以便我可以将其存储到NSUserDefaults 。 问题是该方法继续执行,并没有设置我的variables。 NSLog(@"Begin"); __block NSString *returnAddress = @""; [self.geoCoder reverseGeocodeLocation:self.locManager.location completionHandler:^(NSArray *placemarks, NSError *error) { if(error){ NSLog(@"%@", [error localizedDescription]); } CLPlacemark *placemark = [placemarks lastObject]; startAddressString = [NSString stringWithFormat:@"%@ %@\n%@ %@\n%@\n%@", placemark.subThoroughfare, placemark.thoroughfare, placemark.postalCode, placemark.locality, placemark.administrativeArea, placemark.country]; returnAddress = startAddressString; //[self.view setUserInteractionEnabled:YES]; }]; NSLog(returnAddress); NSLog(@"Einde"); 这是我的应用程序debugging器显示的内容: 开始 einde 例如,如果我的位置的地址是“Mainstreet 32​​,CITY”。 那么我想看到的是以下几点: 开始 Mainstreet 32​​,CITY […]

以编程方式中心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 […]

自定义AlertView与背景

每个人,我需要在UIAlertView上设置一个图像。 我已经附上了我的UIAlertview图像prob .. 我已经使用这个代码行 UIAlertView *theAlert = [[[UIAlertView alloc] initWithTitle:@"Atention" message: @"YOUR MESSAGE HERE", nil) delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease]; [theAlert show]; UILabel *theTitle = [theAlert valueForKey:@"_titleLabel"]; [theTitle setTextColor:[UIColor redColor]]; UILabel *theBody = [theAlert valueForKey:@"_bodyTextLabel"]; [theBody setTextColor:[UIColor blueColor]]; UIImage *theImage = [UIImage imageNamed:@"Background.png"]; theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16]; CGSize theSize = [theAlert frame].size; UIGraphicsBeginImageContext(theSize); [theImage drawInRect:CGRectMake(0, […]

UILabel的backgroundColor是不是animation?

我有一个gridView,我用来显示几个GridViewCell : UIView 。 GidViewCell将UILabel添加到自身,并将UITapGestureRecognizer到自身。 UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)]; [self addGestureRecognizer:gestureRecognizer]; [gestureRecognizer release]; 在tapped:我想玩一些animation,包括改变标签的背景颜色 – (void) tapped:(id)sender { [UIView animateWithDuration:1.0 delay:0 options:(UIViewAnimationOptionAllowUserInteraction) animations:^{ [(UILabel *)[[self subviews] objectAtIndex:0] setBackgroundColor:[UIColor blueColor]]; } completion:^(BOOL finished){ [(UILabel *)[[self subviews] objectAtIndex:0] setBackgroundColor:[UIColor whiteColor]]; } ]; [self.delegate didSelectGridViewCell:self]; } 但是,标签只是一眨眼的蓝色 – 如果有的话。 如果我使用相同的代码,但调整标签的alpha而不是背景颜色,一切都按预期工作。 苹果的文档列出backgroundColor作为animation。 是吗? 难道我做错了什么?

使用播放它的相同button停止声音

很简单,我使用一个button,产生一个随机数字,然后与开关/情况下,它animation图像和播放声音。 我的问题是,当你再次按下button时,以前播放的声音不会停止,声音重叠。 代码如下: – (IBAction) pushme: (id) sender{ int random = (arc4random()%10); switch (random) { case 0: { [ANIMATION NUMBER 0] NSString *path = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] resourcePath],@"/sound0.wav"]; SystemSoundID soundID; NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO]; AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID); AudioServicesPlaySystemSound(soundID); } break; case 1: { [ANIMATION NUMBER 1] NSString *path = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] resourcePath],@"/sound1.wav"]; SystemSoundID […]

iOS上的Dropbox应用程序是否具有URLscheme?

我希望能够在我的应用程序内启动Dropbox应用程序。 因此,我想知道如果Dropbox的应用程序有一个我可以用来调用openURL的URLscheme,除了我不知道这个string应该是什么。 NSURL *myURL = [NSURL URLWithString:@"dropbox://"]; [[UIApplication sharedApplication] openURL:myURL]; 谢谢,

IOS在PDF中embedded字体

我正在绘制一个PDF文件,并不知道如何将字体embedded到PDF本身,任何人都可以帮我吗? 它显示在设备上,但是一旦它通过电子邮件发送或通过AirPrint打印,我只是得到的后备字体。 这是我的代码… – (void) drawChart{ CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(currentContext, 0.0, 0.0, 0.0, 1.0); NSUserDefaults *data = [NSUserDefaults standardUserDefaults]; NSString *pChart1 = [data stringForKey:@"pchart1"]; NSString *textToDraw = [NSString stringWithFormat:@"%@",pChart1]; UIFont *font = [UIFont fontWithName:@"MyFont" size:14]; CGSize stringSize = [textToDraw sizeWithFont:font constrainedToSize:CGSizeMake(pageSize.width – 2*kBorderInset-2*kMarginInset, pageSize.height – 2*kBorderInset – 2*kMarginInset) lineBreakMode:UILineBreakModeWordWrap]; CGRect renderingRect = CGRectMake(kBorderInset + […]