Sal*_*rtz 5 cocoa-touch uiview ios4 ios ios5
我正在开发一个理想的目标应用程序,一直到iOS 3.2.不过,我正在Lion上开发它并使用最新的5 sdk.据我所知,我没有使用任何sdk 5特定功能.但:
在iOS 5或模拟器(设置为v.5)的任何设备上,该应用程序工作得很好.在iOS 4.3或更低版本的任何设备上(设置为v.4.3的模拟器都是如此),与视图帧有关的一些内容会出现错位.
例如,这里有两个例子:
警报视图中的活动指示器.这是代码:
NSURLConnection *urlConnection = [[NSURLConnection alloc] initWithRequest:fileRequest delegate:self];
if(urlConnection)
{
uistatusDialog = [[UIAlertView alloc] initWithTitle:(description ? NSLocalizedString(description, nil) : NSLocalizedString(@"Downloading", nil))
message:nil
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleBottomMargin);
[indicator startAnimating];
[uistatusDialog addSubview: indicator];
[uistatusDialog show];
[indicator release];
Run Code Online (Sandbox Code Playgroud)
以下是两个模拟器的截图:iOS 5:正确
iOS 4.3:未对齐

我通过[UILabel alloc] initWithFrame:CGRectMake(...]设置帧的标签也发生了类似的事情.
这段代码,例如:
UITableViewCell * cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:reuseIndentifier] autorelease];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
UILabel* mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(70, 0, 0, 20)] autorelease];
mainLabel.font = [UIFont boldSystemFontOfSize:(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 18 : 12)];
mainLabel.textAlignment = UITextAlignmentLeft;
mainLabel.textColor = [UIColor blackColor];
mainLabel.backgroundColor = [UIColor clearColor];
mainLabel.autoresizingMask = (UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin);
//mainLabel.adjustsFontSizeToFitWidth = YES;
mainLabel.tag = MAINLABEL_TAG;
Run Code Online (Sandbox Code Playgroud)
在iOS5中可以很好地适应模拟器和设备.但在4.3中却没有.我只能认为本地坐标框架从一个SDK改为另一个SDK?
任何帮助是极大的赞赏!
编辑:现在只是把它拉下来,我最终CGRectMake(x,y,w,h)用一些东西替换了所有的实例(假设x,y,w,h是我用于CGRectMake的那些):
CGrect refFrame = superview.frame;
refFrame.origin.x += x;
refFrame.origin.y += y;
refFrame.size.w = w;
refFrame.size.h = h;
theObjInQuestion.frame = refFrame;
Run Code Online (Sandbox Code Playgroud)
所以基本上,看起来像SDK 5和4.3之间的不同参考框架至少......
4 和 5 之间有一些主要区别,尽管我才刚刚开始弄清楚它们。坐标系发生了一些变化,但我不知道具体是什么。
我有点怀疑最好/最安全的做法是使用两条完全不同的路径来计算布局,直到有人能够找出所有“陷阱”。这样两个版本就可以分别“调整”。
| 归档时间: |
|
| 查看次数: |
852 次 |
| 最近记录: |