iphone-sdk-3.0

how to compare dates in iphone sdk?

人走茶凉 提交于 2019-12-24 07:05:15
问题 i have two dates i want to compare which one is greater date how do i do this in objective-c? 回答1: From NSDate class reference: NSDate -compare: Returns an NSComparisonResult value that indicates the temporal ordering of the receiver and another given date. (NSComparisonResult)compare:(NSDate *)anotherDate Parameters anotherDate The date with which to compare the receiver. This value must not be nil. If the value is nil, the behavior is undefined and may change in future versions of Mac OS X.

UIAlertView Pops Up Three Times per Call Instead of Just Once

时间秒杀一切 提交于 2019-12-24 02:45:34
问题 I am getting odd behavior from an NSAlert in two different parts of my program. The behavior is: Alert appears and then spontaneously disappears. Alert reappears and then remains until dismissed by user i.e. normal behavior. Alert reappears again. This behavior only occurs the first time the method that displays the alert is called. After that first time, it behaves normally. Here is the code for the one of the parts in which the behavior occurs: UIAlertView * locationAlert = [[UIAlertView

Is it possible to hide a UIToolbar with an animation?

*爱你&永不变心* 提交于 2019-12-23 19:08:36
问题 I know this code is available to UINavigationController only. [self.navigationController setNavigationBarHidden:YES animated:YES]; 回答1: An example using blocks. This will hide a toolbar at the top of an iPad screen. [UIView animateWithDuration:.7 animations:^(void) { CGRect toolbarFrame = self.toolbar.frame; toolbarFrame.origin.y = -44; // moves iPad Toolbar off screen self.toolbar.frame = toolbarFrame; } completion:^(BOOL finished) { self.toolbar.hidden = YES; }]; 回答2: Here is the Code:

Modal View using UIModalPresentationFormSheet appears offscreen

六月ゝ 毕业季﹏ 提交于 2019-12-23 19:08:28
问题 I have a UIViewController that implements - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } Then, I try to popup a modal on top of that view: ModalViewController *modalViewController = [[ModalViewController alloc] init]; modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; modalViewController.modalPresentationStyle =

UIImageView in UIView and not to display image parts out of bounds

蓝咒 提交于 2019-12-23 18:52:32
问题 How can I solve the problem I mentioned in the title? So I have an UIImageView and in it there is an UIImage. My UIImageView is in a View. When I set the origin of the imageview to (-120, -30) then I don't want to see the start of my imageview. Is this possible? Can this be done? How? 回答1: Set the clipsToBounds property on the image view to YES. 来源: https://stackoverflow.com/questions/2281939/uiimageview-in-uiview-and-not-to-display-image-parts-out-of-bounds

how can i display image from url?

☆樱花仙子☆ 提交于 2019-12-23 15:50:35
问题 I have a string variable tmpImgURLStr which contains URL like www.abc.com/img.png . i want to display that image in my imageView for that i have use some code but it's not working which is given below: NSLog(@"Img URL === %@",tmpImgURLStr); NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",tmpImgURLStr]]]; UIImage *myimage = [[UIImage alloc] initWithData:mydata]; [logoImg setImage:myimage]; 回答1: As far as I can tell from your url -

struct or class

*爱你&永不变心* 提交于 2019-12-23 09:40:53
问题 I'm developing an iPhone 3.1.3 application. I have a class, called Object2D , with fields and methods; which represent a shape. Object2D has a field that represents its size, and another field that represent its type. Now, I need another class called Pattern , which is a set of shapes. In Pattern I'm going to have an array of shapes. From these shapes I only need their size, their type and their location inside pattern, I don't need any method. I'm wondering it is better to have a new struct

Objective-C changes between OS 2.2.1 and OS 3?

左心房为你撑大大i 提交于 2019-12-23 09:17:36
问题 When I tried compiling my app for OS 3 I encountered an the following error: error: type of accessor does not match the type of property The error was for a property I tried to access that is defined as follows: NSMutableArray *myArray @property (readonly,nonatomic) NSArray* myArray; the property is @synthesized in the implementation file. This worked just fine in OS 2.2.1 but doesn't is OS 3.0 Writing the getter method myself solved the problem. Is anyone aware of changes to objective-c

Objective-C async http request

霸气de小男生 提交于 2019-12-23 07:17:10
问题 I want to create an async http request. Where to start? Can you give me some good links to start this? I want to learn it. 回答1: -[NSURLConnection initWithRequest:delegate:] See Using NSURLConnection from Apple. 回答2: http://cocoawithlove.com/2008/09/cocoa-application-driven-by-http-data.html 回答3: You can use third party SDK like ASIHTTPRequest . It is very simple to use and come with some delegate methods. This is how you can use it. It is really useful as it provide a lot of features. 来源:

How to rotate image 360 degrees endlessly using iPhone SDK?

最后都变了- 提交于 2019-12-23 05:12:34
问题 I want to rotate image 360 degrees endlessly using iPhone SDK? How can this be done? Thanks! 回答1: -(void)startAnimationWithRevolutions:(float)revPerSecond forTime:(float)time { spinWheel.userInteractionEnabled = FALSE; float totalRevolutions = revPerSecond * time; [CATransaction begin]; [CATransaction setValue:[NSNumber numberWithFloat:time] forKey:kCATransactionAnimationDuration]; CABasicAnimation* spinAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];