Tag: Objective C

自动布局具有dynamic高度子视图的UIScrollView

我遇到了使用自动布局约束的UIScrollView问题。 我有以下视图层次结构,通过IB设置约束: – ScrollView (leading, trailing, bottom and top spaces to superview) — ContainerView (leading, trailing, bottom and top spaces to superview) — ViewA (full width, top of superview) — ViewB (full width, below ViewA) — Button (full width, below ViewB) ViewA和ViewB的初始高度为200点,但点击它可以垂直消耗400点的高度。 ViewA和ViewB通过更新高度约束(从200到400)进行扩展。 这里是相应的片段: if(self.contentVisible) { heightConstraint.constant -= ContentHeight; // + additional View's internal constraints […]

为什么我在iOS 7上以编程方式创build屏幕截图看起来很糟糕?

我正试图实现与Facebook分享应用程序。 我用这个代码来截图: CGSize imageSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height); UIGraphicsBeginImageContext(imageSize); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); 它在iOS 6上效果很好,但在iOS 7中,图像看起来非常糟糕。 我使用了这个答案: iOS:什么是以编程方式制作截图的最快,最高效的方法? 试图修复它,并帮助,仍然截图看起来不好。 屏幕获得另一种颜色,并且一些对象(如标签)不会显示在拍摄的图像上。 任何帮助? —- —-更新 我设法解决最多的对象,通过改变他们保留而不是弱。 我的主要问题仍然是我的桌面视图,显示为一个大的白色块(它应该是透明的,带有白色文本的标签,所以我们看到的只是白色的单元格)。 我确实尝试将表格背景定义为clearcolor,没有帮助。 – – 最后更新 – – 这里有很好的答案,不是真的关于我的问题..我想让它在iOS7上运行的设备上工作,但不使用iOS7 SDK,因为在这一点上切换项目SDK需要很多努力,当项目几乎完成了。 无论如何,我添加了代码的和平,终于解决了我的问题: 这个改变只是解决了这个问题: UIGraphicsBeginImageContextWithOptions(imageSize, NO , 0.0f); 代替: UIGraphicsBeginImageContext(imageSize);

发送一个文件作为附件在目标c

我想通过从图像select器中select一个文件(图像)作为附件邮寄。 在iOS Objective-C中,我可以附加和发送文件(特别是图像)的适当方式是什么?

如何在IOS中做慢动作video

我必须在video文件中伴随audio,在一些帧之间进行“ 慢动作 ”,并且需要将渐变video存储为新video。 参考: http : //www.youtube.com/watch?v = BJ3_xMGzauk (从0到10秒钟) 从我的分析,我发现AVFoundation框架可以是有帮助的。 参考: http : //developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/00_Introduction.html 从上面的链接复制并粘贴: “编辑AV Foundation使用合成来创build现有媒体(通常是一个或多个video和audio轨道)的新资产,使用可变的合成来添加和移除轨道,并调整它们的时间顺序,还可以设置相对音量和渐变音轨;以及设置video轨道的不透明度和不透明度斜坡,合成是内存中保存的多个媒体的集合,当您使用导出会话导出合成时,它将合并到一个文件中。 iOS 4.1及更高版本,您还可以使用资产编写器从媒体(如样本缓冲区或静态图像)创build资产。 “ 问题: 我可以使用AVFoundation框架“慢动作”video/audio文件吗? 还是有其他可用的包吗? 如果我想单独处理audio和video,请指导我如何做? 更新::代码AV导出会话: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *outputURL = paths[0]; NSFileManager *manager = [NSFileManager defaultManager]; [manager createDirectoryAtPath:outputURL withIntermediateDirectories:YES attributes:nil error:nil]; outputURL = [outputURL stringByAppendingPathComponent:@"output.mp4"]; // Remove Existing File [manager […]

如何使用AVFoundation结合不同方向的video剪辑

我正在尝试将几个video剪辑合并为一个使用AVFoundation。 我可以使用下面的代码使用AVMutableComposition创build一个video AVMutableComposition *composition = [AVMutableComposition composition]; AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid]; CMTime startTime = kCMTimeZero; /*videoClipPaths is a array of paths of the video clips recorded*/ //for loop to combine clips into a single video for (NSInteger i=0; i < [videoClipPaths count]; i++) { NSString *path = […]

UIScrollview获取触摸事件

我如何检测我的UIScrollView触摸点? 触摸委托方法不起作用。

Objective-C中的类属性列表

有没有办法获得某种类的属性数组? 例如,如果我有像这样的接口 @interface MyClass : NSObject @property (strong,nonatomic) UILabel *firstLabel; @property (strong,nonatomic) UILabel *secondLabel; @end 我可以在不知道名字的情况下获得对这些标签的引用吗? @implementation MyClass -(NSArray*)getListOfAllLabels { ????? } @end 我知道我可以用[NSArray arrayWithObjects:firstLabel,secondLabel,nil]轻松地做到这一点,但我想用某种类的枚举类似于for (UILabel* oneLabel in ???[self objects]???)

UIGestureRecognizer阻止子视图处理触摸事件

我试图弄清楚这是如何做到正确的 。 我试图描绘的情况: 我添加一个UITableView作为UIView的子视图。 UIView响应pinchGestureRecognizer和pinchGestureRecognizer ,但是当这样做时,tableview停止对这两个手势作出反应(它仍然对滑动作出反应)。 我已经使它与下面的代码工作,但它显然不是一个很好的解决scheme,我敢肯定有一个更好的方法。 这是放在UIView (超级视图): -(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { if([super hitTest:point withEvent:event] == self) { for (id gesture in self.gestureRecognizers) { [gesture setEnabled:YES]; } return self; } for (id gesture in self.gestureRecognizers) { [gesture setEnabled:NO]; } return [self.subviews lastObject]; }

NSDateFormatter:date根据currentLocale,无年份

这不能太困难.. 我想显示一个没有年份的date。 例如:“8月2日”(美国)或“02.08”。 (德国)它也必须适用于其他一些地区。 我到目前为止唯一的想法是做一个正常的格式与年,然后从生成的string中删除年份。

从webservicesurl获取密码并通过该密码进行访问

我有一个Web服务URL附加访问码。 我需要将访问码发布到一个web服务url并获得json响应。 我得到正确的访问代码和不正确的访问代码的JSON响应。 我没有得到问题出现的地方。 当input错误的密码时,我需要显示警报,这里是我的代码。 NSString *post =[[NSString alloc] initWithFormat:@"txtsecurecode=%@",[txtsecurecode text]]; NSLog(@"PostData: %@",post); NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]]; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://my example.com/Accountservice/Security/ValidateAccess?accesscode=abcdtype=1"]]]; NSURL *url; // I need to parse it into url here . [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request […]