Tag: cocoa触摸

NSURLConnection sendAsynchronousRequest – 与HTTPS通信

我正在从一个URL获取图像的iPhone应用程序。 我正在使用'NSData dataWithContentsOfUrl]它工作正常。 但是,正如你可能猜到的那样,这个请求是同步的。 我希望这个请求是asynchronous的。 所以,我尝试使用NSURLConnection的sendAsynchronousRequest()调用。 但是这会在方法'didFailWithError'中返回以下错误: 错误域= kCFErrorDomainCFNetwork代码= 310“与安全Web代理服务器(HTTPS)通信时出现问题。 有人可以帮忙吗? 这是我的NSURLConnection代码片段: NSURL *url = [NSURL URLWithString:notePicUrl]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:100.0]; //NSOperationQueue *queue = [[NSOperationQueue alloc] init]; NSURLConnection* _connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self startImmediately:NO]; self.port = [NSPort port]; self.runLoop = [NSRunLoop currentRunLoop]; [self.runLoop addPort:self.port forMode:NSDefaultRunLoopMode]; [_connection scheduleInRunLoop:self.runLoop forMode:NSDefaultRunLoopMode]; [_connection start]; while […]

iOS 5,故事板:为每个UIView自定义以编程方式创build的UITableView

在故事板中,我创build了一个UIViewController,并将更多的两个UIViews添加到同一个故事板。 然后添加UISegmentedControl来启用这些UIViews之间的切换。 我用来在UIView之间切换的方法: -(IBAction)segmentValueChaged:(id)sender { if(self.segment.selectedSegmentIndex==0) { [self.coinageView removeFromSuperview]; [self.view addSubview:nominalsView]; [self populateNominals:self.subCountryID]; } else { [self.nominalsView removeFromSuperview]; [self.view addSubview:coinageView]; } } 以及在UIView上添加UITableView的方法: -(void)populateNominals:(int)subCountryID { UITableView *nominalsTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 372) style:UITableViewStylePlain]; //nominalsTableView.dataSource = self; //nominalsTableView.delegate = self; [self.nominalsView addSubview:nominalsTableView]; } 这种方法工作正常,我得到一个表切换段时popup。 我的问题是,我可以在哪里定制每个段(UIView)的每个tableView? 问题是我需要两个相当不同的表(不同的devise,cellForRowAtIndexPath和不同的导航,而didSelectRowAtIndexPath)。 先谢谢你。

在NSUserDefaults中加载数据

我已经做了编码,以保存高分在NSuserdefaults,但我不知道如何加载数据从nsuserdefaults并显示在表中。 请帮忙。 NSString *name; name = nametextbox.text; NSDictionary *player = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithFormat:@"%@", name], @"name",[NSString stringWithFormat:@"%d", myScore], @"score",nil]; [highScore addObject:player]; NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"score" ascending:NO]; [highScore sortUsingDescriptors:[NSArray arrayWithObject:sort]]; [sort release]; [[NSUserDefaults standardUserDefaults] setObject:highScore forKey:@"highScore"];

如何使用NSCoding对通过委托传递的值进行编码

我真的很新,使用NSCodingfunction,我试图创build一个归档string的数据的持久性,特别是通过委托传递的UIColor。 我还没有find一个教程,编码的值没有声明和初始化在NSCoding协议符合相同的类。 我有下面的代码,这是符合我创build的协议的方法,并将传递的颜色值作为属性赋值给attributesString。 func didSelectColorCell(color: UIColor) { let coder = NSCoder.init() color.encode(with: coder) noteTextView.setAttributedValueAtSelectedTextRange(NSForegroundColorAttributeName, value: color) } 该应用程序崩溃,并发送给我一个警告:“不能被发送到类NSCoder的抽象对象:创build一个具体的实例! 我真的迷失在如何进行。 我不知道如何使这个教程http://nshipster.com/nscoding/适应我的情况。 有人可以给我提供指导如何订购我的想法,或NSCoding如何与代表工作? 任何帮助,将不胜感激 :)

有没有办法在数组中复制NSDictionaries的数量?

我目前在我的表格视图中有这个NSDictionary数组,但是我需要在表格视图向下滚动时复制数组中的字典数。 有没有办法做到这一点,还指定或知道什么字典名称将? NSMutableDictionary *d0 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d1 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d2 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d3 = [[NSMutableDictionary alloc] init]; NSMutableDictionary *d4 = [[NSMutableDictionary alloc] init]; objects = [NSMutableArray arrayWithObjects:d0, d1, d2, d3, d4, nil];

在UIPopover中显示UINavigationController内容偏移量

我有一个视图,我加载到一个UINavigationController并作为iPad上的popup窗口或iPhone上的模态视图。 我遇到的奇怪现象是,当这个导航出现在popup窗口中时,它的内容会出现偏移或下推大约60个像素。 下面是这个现象的截图。 它目前看起来是这样,因为我把我的最高约束设置为80,补偿了iPhone。 如果我把它设置为更直观的东西,如10或20,标签将完全隐藏在iPhone导航栏下,而popup窗口显示正确。 任何build议? 我知道我可以手动调整顶部约束基于它是在一个模式或popup窗口,但我宁愿改变导航栏上的一些属性,以禁用偏移或类似的东西,因为使用设备成语已被苹果现在弃用: – ( 提前致谢。

如何从故事板上的视图控制器获取子视图

我有两个视图控制器,每个都有一个UIView它有一个标签。 我想将第一个视图控制器的视图设置为按下button时的第二个视图。 当我这样做时,第二个视图控制器不会加载视图,并且指针在我的第二个视图上的UIView为空,所以我不能在我的第一个视图上做任何事情。 我所做的就是这个,因为我的secondViewNew是我的secondView属性。 这是可能在故事板上完成吗? 我也尝试了[self.storyboard instantiateViewControllerWithIdentifier:@“beaconContentID”]做事情的方法。 在这个项目中,secondViewNew也是一个UIView,并且我导入了所有相关的类。 SecondViewController *secondViewControllerInstance = [[SecondViewController alloc] init]; UIView *test = secondViewControllerInstance.secondViewNew; NSLog(@"%@",test);

UIPinchGestureRecognizer仅用于捏出

我试图创build一个UIPinchGestureRecognizer失败,如果用户捏(移动手指分开)。 我知道有一个非常简单的方法来做到这一点,只是采取行动方法的识别器的规模,如果它大于1,设置一个标志,并忽略所有未来的呼叫。 然而,这不适用于我,我有其他的手势识别器,需要这个捏认识失败,所以我需要它正确地失败时,用户捏在错误的方向。 我试图inheritanceUIPinchGestureRecognizer: @implementation BHDetailPinchGestureRecogniser { CGFloat initialDistance; } #pragma mark – Object Lifecycle Methods – (id)initWithTarget:(id)target action:(SEL)action { self = [super initWithTarget:target action:action]; if (self) { initialDistance = NSNotFound; } return self; } #pragma mark – UIGestureRecogniser Methods – (BOOL)shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)recogniser { if ([recogniser isKindOfClass:[UIPinchGestureRecognizer class]]) { return [self.delegate gestureRecognizerShouldBegin:self]; } else return […]

在iOS 7中,长按屏幕标题缺lessbutton标题

当我的屏幕标题很大时,我看到“返回”button标题丢失。 我需要显示整个标题。 有没有解决方法? 请参阅附上我看到与长标题的导航栏的屏幕截图。

coredata keypath nameOfMovie找不到实体<NSSQLEntity Theaters id = 3>

我有一个coredata项目,我试图做一个查询。 这是我的coredata模型: NSManagedObjectContext *moc = [self managedObjectContext]; NSEntityDescription *theaterDescription = [ NSEntityDescription entityForName:@"Theaters" inManagedObjectContext:moc]; NSPredicate *theaterPredicate = [NSPredicate predicateWithFormat:@"nameOfTheater like %@ AND nameOfMovie like %@",_theaterName,_movieOutlet.stringValue]; NSFetchRequest *theaterRequestTwo = [NSFetchRequest new]; theaterRequestTwo.entity = theaterDescription; theaterRequestTwo.predicate = theaterPredicate; NSError *error = nil; NSArray *theaterResults = [moc executeFetchRequest:theaterRequestTwo error:&error]; 但是我得到这个错误: keypath nameOfMovie not found in entity <NSSQLEntity Theaters […]