Problems and solutions for iOS when writing a project

Source: Internet
Author: User

1. Solve the problem that Headerview does not scroll with the cell

Solution: Myheaderview The view you created for yourself on Tableheadview, self.tableview.tableheadview=myheaderview;2. Remove TableView Redundant form-line solution: Tableview.tablefooterview=[[uiview Alloc]init];3.uicolor's RGBA definition color (colorwithred) Solution: The Uicolor is often used as an interface, which is an Apple class that represents color. Want to represent a color, Uicolor has the default color, Whitecolor,blackcolor ... You can also initialize colors with RGB and, of course, an alpha transparency. My code is like this. Uicolor *color = [Uicolor colorwithred:9 green:122 blue:255 alpha:1]; never reach the desired effect (9,122,255) .... Check online, and then look at the introduction of this method, the RGB and Alpha values range is 0~1, so 9,122,255 is treated as 255. Correct: Uicolor *color = [Uicolor colorwithred:9.0/255.0 green:122.0/255.0 blue:50.0/255.0 alpha:1];4. Xcode update 6.4 on AppStore, always pop up someone else's account resulting in the solution cannot be updated: Because your itunes app has some of the software used in other people's accounts purchased or authorized, you need to delete them re-download in order to use their own account Update 5. The app was encountered during a real machine test Install fail solution: Delete the app in the phone, then installed the new app, because the configuration file may be different before and after the app, resulting in no real machine test 6. Mjrefresh, refresh application download import Mjrefresh library, import header file;add a few lines of code to it.

Self.tableView.header = [Mjrefreshnormalheader headerwithrefreshingblock:^{

This block is automatically called when the refresh State is entered

Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (2.0 * nsec_per_sec)), Dispatch_get_main_queue (), ^{

[Self.newstv Reloaddata];

});

}];

Self.tableView.footer = [Mjrefreshautonormalfooter footerwithrefreshingblock:^{

This block is automatically called when the refresh State is entered

Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (2.0 * nsec_per_sec)), Dispatch_get_main_queue (), ^{

[Self.newstv Reloaddata];

});

}];

7. Set the app not to turn the screen, maintain the vertical state solution: 1. Modify the supported interface orientations of the Info.plist file 2. Add-(BOOL) appdeledate in shouldautorotate{ return NO;

}

-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation

{

return interfaceorientation = = Uiinterfaceorientationportraitupsidedown;

}

8. Forced rotation problem

Problem solved, still perfect. The basic principle of the method is still the same, forcing the system to invoke the automatic rotation mechanism.


Vertical screen Click button to rotate to horizontal screen
[[Uidevice Currentdevice] setvalue:[nsnumber numberwithinteger:uideviceorientationportrait] forKey:@ "orientation"] The phrase is to prevent the device from being manually placed horizontally, causing the following statement to fail.
[[Uidevice Currentdevice] setvalue:[nsnumber Numberwithinteger:uideviceorientationlandscapeleft] forKey:@ " Orientation "];

Horizontal screen Click button, rotate to vertical screen
[[Uidevice Currentdevice] setvalue:[nsnumber Numberwithinteger:uideviceorientationlandscapeleft] forKey:@ " Orientation "];//This sentence is to prevent manually first put the device into a vertical screen, resulting in the following statement invalid.
[[Uidevice Currentdevice] setvalue:[nsnumber numberwithinteger:uideviceorientationportrait] forKey:@ "orientation"] ;

You also have to support automatic rotation
-(BOOL) shouldautorotate
{
return YES;
}

Then there is
-(Nsuinteger) supportedinterfaceorientations
{
if (Is_iphone && self.ishalfscreen) {//If it is an IPHONE and it is a vertical screen, only vertical screen is supported
return uiinterfaceorientationmaskportrait;
}
return uiinterfaceorientationmasklandscape; No people only support horizontal screen
}

Here is the basic. 9. "The identity used to sign the executable is no longer valid" Error resolution workaround, download the development.apple.com profile again to the provision website Double-click Install to Xcode and run.Objective-c-Gets the millisecond timestamp:

Get method:

UInt64 recordtime = [[NSDate date] timeintervalsince1970]*1000;
first [[NSDate Date] timeIntervalSince1970] is able to get to the back of the millisecond microsecond, just omitted at the time of saving, such as a timestamp does not omit the case is 1395399556.862046, omitted after the general see 1395399556. So when you want to get milliseconds, use the time stamp *1000 to obtain the time stamp * 1000 * 1000 when you want to take microseconds.

If you want to format the output you can:

NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
[Formatter setdateformat:@ "Yyyy-mm-dd Hh:mm:ss:SSS"];
NSString *date =  [formatter stringfromdate:[nsdate Date]];
NSString *timelocal = [[NSString alloc] initwithformat:@ "%@", date];
NSLog (@ "%@", timelocal);
11.
Adaptive text Height

Cgsize size = Cgsizemake (viewwidth, 1000);

Cgsize labelsize = [Self.strarr[indexpath.row] Sizewithfont:[uifont systemfontofsize:14] ConstrainedToSize:size Linebreakmode:nslinebreakbyclipping];

return labelsize.height+40;

Problems and solutions for iOS when writing a project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.