Tag: Objective C

ARC – __unsafe_unretained的含义?

只是想确保我说得对: 我是否需要__unsafe_unretain我不拥有的对象? 如果一个对象是__unsafe_unretained我是否需要在@property使用assign ? 这是否意味着对象不被保留,只是指向我分配的对象? 我何时想使用它,除了代表? 这是一个ARC的事情还是之前使用?

在iOS 7中强制横向ViewController

我在纵向模式下有十多个ViewController,但是无论设备的方向如何,我都需要在横向模式下强制一个ViewController。

我如何得到WhatsApp在iOS构成消息给特定用户?

我如何得到WhatsApp阿比特组成一个特定的用户消息? 我想在我的应用程序中select联系人时发送短信。 这是我的代码: NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?abid=XXX"]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; } WhatsApp官方链接: https : //www.whatsapp.com/faq/iphone/23559013

EXC_BAD_ACCESS in heightForRowAtIndexPath iOS

我正在一个应用程序,我有一个自定义的UITableViewCell的子类。 我想根据里面的文本使单元格的高度dynamic化。 我尝试在我的heightForRowAtIndexPath方法中做到这一点。 但是我有一些问题,下面的代码会导致EXC_BAD_ACCESS(code = 2 address = 0xb7ffffcc)的错误。 – (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { PostCell *cell = (PostCell *)[tableView cellForRowAtIndexPath:indexPath]; CGSize postTextSize; if (![cell.postText.text isEqualToString:@""]) { postTextSize = [cell.postText.text sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(cell.postText.frame.size.width, 200)]; } else { postTextSize = CGSizeMake(cell.postText.frame.size.width, 40); } return postTextSize.height + cell.userName.frame.size.height + 10; } 如果我反而有: – (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath […]

将子视图控制器添加到当前视图控制器

我试图通过使用下一个代码添加一个子视图控制器的代码,从故事板到当前的视图控制器: UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; LogInTutorialViewController *lvc = [[LogInTutorialViewController alloc] init]; lvc = (LogInTutorialViewController *)[storyboard instantiateViewControllerWithIdentifier:@"LogInTutorialViewControllerID"]; [self displayContentController:lvc]; – (void) displayContentController: (LogInTutorialViewController*) content; { //add as childViewController [self addChildViewController:content]; [content didMoveToParentViewController:self]; [content.view setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)]; [self.view addSubview:content.view]; } 视图似乎至less在模拟器上显示,但在控制台我得到很多或错误: <Error>: CGContextSaveGState: invalid context 0x0. This is a serious error. […]

在Swift中将hexstring转换为NSData

我得到了在Objective-C中将string转换为HEX-String的代码。 – (NSString *) CreateDataWithHexString:(NSString*)inputString { NSUInteger inLength = [inputString length]; unichar *inCharacters = alloca(sizeof(unichar) * inLength); [inputString getCharacters:inCharacters range:NSMakeRange(0, inLength)]; UInt8 *outBytes = malloc(sizeof(UInt8) * ((inLength / 2) + 1)); NSInteger i, o = 0; UInt8 outByte = 0; for (i = 0; i < inLength; i++) { UInt8 c = inCharacters[i]; SInt8 value […]

在iOS5中使用Twitter框架提示login提醒?

大家可能知道,由于iOS5有一个原生的Twitter框架,可以很容易地从你的应用程序发布推文。 有没有办法提示提醒用户转到设置应用程序并要求input用户名和密码? 我知道我可以用下面的代码解决问题: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]]; 但那是没有文件的代码.. 提前致谢 关心比利(我的第一篇文章)

沿着贝塞尔path放置图像

有谁知道如何沿着贝塞尔path放置图像? 我可以写好path并沿pathanimation一个精灵,但是我想让path成为一系列箭头而不是虚线。 我认为必须有一种方法可以在path上添加箭头图像,但无法find它。 path也是弯曲的: UIBezierPath * path = [UIBezierPath bezierPath]; [path moveToPoint:startingPoint]; [path addCurveToPoint:endPoint controlPoint1:controlPoint1 controlPoint2:controlPoint2];

如何用六angular形蒙版圆angularUIImage

我试图添加一个六边形蒙版到我已经成功的UIImage。但是我无法圆六边形蒙版的两侧。 我想joincell.profilePic.layer.cornerRadius = 10; 会做的伎俩,但它没有。 这是我的代码: CGRect rect = cell.profilePic.frame; CAShapeLayer *hexagonMask = [CAShapeLayer layer]; CAShapeLayer *hexagonBorder = [CAShapeLayer layer]; hexagonBorder.frame = cell.profilePic.layer.bounds; UIBezierPath *hexagonPath = [UIBezierPath bezierPath]; CGFloat sideWidth = 2 * ( 0.5 * rect.size.width / 2 ); CGFloat lcolumn = ( rect.size.width – sideWidth ) / 2; CGFloat rcolumn = rect.size.width – […]

POST请求不考虑NSMutableURLRequest超时间隔

我有以下问题。 在使用HTTP方法POST的NSMutableURLRequest ,为连接设置的超时间隔被忽略。 如果互联网连接有问题(代理错误,错误的DNS),约2-4分钟后url请求失败,但NSLocalizedDescription = "timed out";不会NSLocalizedDescription = "timed out"; NSUnderlyingError = Error Domain=kCFErrorDomainCFNetwork Code=-1001 UserInfo=0x139580 "The request timed out. 如果使用的http方法是GET它工作正常。 通过https连接是async 。 NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setTimeoutInterval:10]; //Set the request method to post [request setHTTPMethod:@"POST"]; if (body != nil) { [request setHTTPBody:body]; } // Add general parameters […]