cocoa-touch

Passing variables through classes in Objective-C

我的未来我决定 提交于 2020-01-06 10:12:20
问题 In my scenario I have 2 view controllers, one tied to the main view and one that is connected to the first one as a subview. Now let's say that my App Delegate class wants to pass a string to the subview controller. What is the best practice to achieve this? If I wanted to pass it to the 1st controller i could just say something like [self.firstController getStringInCustomFunction:[NSString stringWithFormat:@"200%d", 9]]; Also keep in mind that this call might have to be asynchronous. Coming

Label in two rows

橙三吉。 提交于 2020-01-06 09:02:56
问题 I have a label in 2 lines in my app but the last word in the first line breaks in two rows. For example if last word is 'home' I have h in the first line and ome in the second. How can I fix that? UPDATE : Put over IB and in code word wrap but without success. Code part: ... cell.leftArticleTitleLabel.lineBreakMode = NSLineBreakByWordWrapping; [cell.leftArticleTitleLabel setLineBreakMode:TRUE]; cell.leftArticleTitleView.frame = CGRectMake(cell.leftArticleTitleView.frame.origin.x, 40, 159, 40)

Text in UISegmentedControl not exactly centered?

最后都变了- 提交于 2020-01-06 08:25:14
问题 Maybe it's just me, but it seems like the bottom padding is greater than the top padding for the text in this UISegmentedControl . Why is this happening? 回答1: The position is probably correct, but it looks wrong to your eye because room is left for a descender, and there are no descenders because the titles are all caps. Luckily, you can adjust the y -component of the content position! There are two ways: In Interface Builder, in the attributes inspector for each segment, set the Content

Speed up the response retriever from server in iphone

雨燕双飞 提交于 2020-01-06 08:10:59
问题 I am using following code to get results from server NSString *queryString = @"MyString" NSString *response = [NSString stringWithContentsOfURL:[NSURL URLWithString:queryString] encoding:NSUTF8StringEncoding error:&err]; NSLog(@"%@",response); if (err != nil) { UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Error" message: @"An error has occurred. Kindly check your internet connection" delegate: self cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; [indicator

UINavigationController transition animations triggered too fast

倾然丶 夕夏残阳落幕 提交于 2020-01-06 08:10:23
问题 I'm using a custom-made container view controller in my dictionary app. Basically, the container view controller contains a custom navigation bar on top ( NOT a UINavigationBar --just a UIView with back and forward UIButtons , a UISearchBar , and a bookmark UIButton at the right), and a tab bar controller at the bottom. My problem is this: I use the back and forward buttons to push and pop view controllers in one of the tabs (a UINavigationController ) so the user can navigate through the

UISlider only slide a small distance

喜夏-厌秋 提交于 2020-01-06 08:09:49
问题 So I've put a UISlider into a view with the following code, but it could only be slided for the distance of about 10 points a time. It can only be dragged back and forth within a range of about 20 points. Why? v = [[UIView alloc] initWithFrame:someFrame]; UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(10, 10, 200, 30)]; [v addSubview:slider]; [self.view addSubview:v]; I've put this code into another test project, it does work. So it might be some other code. I'm wondering if

Drag, scale and rotate multiple UIImageviews

*爱你&永不变心* 提交于 2020-01-06 08:04:33
问题 I've got it so far that I can move, scale and rotate all the objects, but the multiple objects all move together. I want them to move seperate. I guess I have to change the objectatIndex to 1, but it just crashes. I've used the following code: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSArray *allTouches = [touches allObjects]; UITouch* t; if([[event allTouches] count]==1){ if (CGRectContainsPoint([Birdie frame], [[allTouches objectAtIndex:0] locationInView

Swiffy output transparent background

荒凉一梦 提交于 2020-01-06 07:54:39
问题 I'm just trying to figure out a way to use a swiffy outputted HTML5 animation in an iOS app but I can't drop the grey background. I thought this would be a way to drop animations in and circumvent the storage issues of using a png on a retina iPad display. Now I can't make the background clear. What should I do? 回答1: In the code that Swiffy generated, look for backgroundColor and remove it including its value. 回答2: Try to locate element with solid background and change it dynamically to

xml parsing iphone, objective C?

南笙酒味 提交于 2020-01-06 07:25:10
问题 i want to get data between xml tags? how to navigate? and get values.. im using wsdl2objc from google code:http://code.google.com/p/wsdl2objc/ output soapbody follows: read instruction here: http://code.google.com/p/wsdl2objc/wiki/UsageInstructions my header file: #import "MService.h" how to get image source and text value???? please help me.... 回答1: if([bodyPart isKindOfClass:[types_getFavoriteColorResponseType class]]) { types_getFavoriteColorResponseType *body = (types

How to get a list of the playlists and songs in an iPhone/iPod Touch?

核能气质少年 提交于 2020-01-06 06:28:09
问题 Can I get a list of the playlists and songs in each playlist in an iPhone? This is for a legal app. so hidden APIs/jailbroken solutions don't apply. 回答1: You have to wait for 3.0, currently it is not possible. The 3.0 API is currently considered confidential by Apple, so that I probably should not say more, but You can read the API details on the website. 回答2: You can't do it with the 2.x public APIs, and the 3.x is under a NDA, so it can't be discussed here. 回答3: It should be noted that