cocoa-touch

How do I override the “view” property in UIViewController?

五迷三道 提交于 2019-12-30 01:37:47
问题 I have a custom UIViewController and custom UIView. I'd like to override the viewcontroller.view property to return MyCustomUIView. Right now I have: @interface MyViewController : UIViewController { IBOutlet MyView* view; } @property (nonatomic, retain) IBOutlet MyView* view; This compiles but I get a warning: property 'view' type does not match super class 'UIViewController' property type. How do I alleviate this warning? 回答1: The short answer is that you don't. The reason is that properties

Resizing an image with stretchableImageWithLeftCapWidth

♀尐吖头ヾ 提交于 2019-12-30 00:50:51
问题 I'm trying to resize an image using stretchableImageWithLeftCapWidth: it works on the simulator, but on the device, vertical green bars appears. I've tried to use imageNamed, imageWithContentOfFile and imageWithData lo load the image, it doesnt change. UIImage *bottomImage = [[UIImage imageWithData: [NSData dataWithContentsOfFile: [NSString stringWithFormat:@"%@/bottom_part.png", [[NSBundle mainBundle] resourcePath]]]] stretchableImageWithLeftCapWidth:27 topCapHeight:9]; UIImageView

changing the color of image in iphone sdk

青春壹個敷衍的年華 提交于 2019-12-30 00:49:33
问题 I have a image & i want to change the color of that image through programatically. & I want to change the color of this image 回答1: UPDATE: Use this method... -(UIImage *)imageNamed:(NSString *)name withColor:(UIColor *)color { // load the image UIImage *img = [UIImage imageNamed:name]; // begin a new image context, to draw our colored image onto UIGraphicsBeginImageContext(img.size); // get a reference to that context we created CGContextRef context = UIGraphicsGetCurrentContext(); // set the

Swift - Tinder effect

百般思念 提交于 2019-12-30 00:48:05
问题 How can I achieve Tinder effect in Swift? I mean, I have an image and want to accept if I swipe to right and reject if I swipe to left. I can do it with the code bellow: @IBAction func SwipeRight(sender: UISwipeGestureRecognizer) { UIView.animateWithDuration(1) { self.Imagem.center = CGPointMake(self.Imagem.center.x - 150, self.Imagem.center.y ) } //other things after acception } and @IBAction func SwipeLeft(sender: UISwipeGestureRecognizer) { UIView.animateWithDuration(1) { self.Imagem

Using Interface Builder for UITableViews

落花浮王杯 提交于 2019-12-30 00:44:08
问题 I'm very early in the iPhone development learning process. I'm trying to get my head around various pieces. Right now I've just taken the basic NavigationController template and I'm trying to create a simple grouped table view with a couple of text fields. What I can't seem to do is to get Interface Builder to allow me to drop a UITableViewCell into a UITableView so that I can then add a text field to the Cell. Is this even possible (it would seem that its supposed to be given the fact that

How to Cancel Scrolling in UIScrollView

守給你的承諾、 提交于 2019-12-30 00:37:10
问题 I use UIScrollView to make large-sized (larger than 320px) UI on iPhone. I made an instance of UIScrollView and added some subviews on it. The problem is that I want to enable scrolling only when user touches outside of subviews, stop scrolling when user touches one of subviews. I read documents and tried to find samples but I can't find good hint. If you have any idea, please help me. 回答1: If you want to detect touches inside any of the subviews of the UIScrollView, you will have to subclass

How can I programmatically generate a thumbnail of a PDF with iOS?

一曲冷凌霜 提交于 2019-12-30 00:19:05
问题 We're displaying PDF content using UIWebViews at the moment. Ideally I would like to be able to display thumbnails in the UITableView without loading many different UIWebViews concurrently... they're slow enough loading one document - never mind 10+! How do I go about doing this? I've thought about screen capturing a document loaded using UIDocumentInteractionController or UIWebView but this means they'd all have to be thumbnailed before displaying the table. 回答1: Apple supply a whole bunch

How to dismiss a modal that was presented in a UIStoryboard with a modal segue?

随声附和 提交于 2019-12-30 00:17:09
问题 Setup: I have a storyboard set up, with two simple view controllers A and B. There is a button in A, that transitions to B with a modal segue. B is presented with a modal transition on top of A. It’s fine. Question: is there a way to pop B away and get back to A with some simple storyboard magic? Note that if this was all in a navigation controller, and I used a push segue, it would be implicitly be taken care of by navigation controller. There would be a “back” button. There’s nothing

Custom inputView for UITextField , how do I direct input back to the text field?

旧街凉风 提交于 2019-12-29 22:06:17
问题 I have set a custom inputView to my UITextField . I need a way to display the data selected in my custom inputView in the UITextfield . I would like to achieve this the same way the system keyboard does it. Does anyone know how this is done? How does the system keyboard get a reference to the UITextfield that is the first responder? 回答1: How does the system keyboard get a reference to the UITextfield that is the first responder? It just asks the system for the first responder; unfortunately,

UIImagePickerController bug

自古美人都是妖i 提交于 2019-12-29 19:49:11
问题 I think I found a bug in latest iOS 7 by running an app with Base SDK set to iOS 6.1 (possibly even lower versions too, haven't tested that out yet) I have this image in my photo library: http://i.imgur.com/7KUIGLt.jpg I present a UIImagePickerController via: UIImagePickerController *vc = [[UIImagePickerController alloc] init]; vc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; vc.delegate = self; vc.allowsEditing = YES; [self presentViewController:vc animated:YES completion:nil];