使用UITextView时的性能问题
我遇到性能问题。
我开发了一个应用程序,没有任何问题 通过导航,该应用程序运行顺利。 直到我添加了 UITextView,单击时 将视图切换到所在视图的按钮 我使用的是TextView,大约需要4到5秒的时间 切换视图。填充textView时会发生这种情况 大约有30-40行文字。
我使用界面生成器添加了 TextView,whiteout 在 Xcode 中添加与 UITextView 相关的任何代码。
你能帮我解决这个问题吗?
谢谢。
编辑:这是包含 TextView 的页面的代码
// Food.m
// Azkar
//
// Created by al3madi on 18/02/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "Food.h"
#import "MainMenuViewController.h"
@implementation Food
- (IBAction) mainMenu:(id)sender {
MainMenuViewController* mainM = [[MainMenuViewController
alloc] initWithNibName:@"MainMenuViewController" bundle:nil];
[self.navigationController pushViewController:mainM animated:YES];
}
- (void)dealloc {
[MainMenuViewController release];
[super dealloc];
}
@end
注意:我已使用 Interface Builder 在 XIB 文件中输入文本,而不是通过编码,其中我已将 TextView 的内容更改为我想要的文本。我还做了 TextView 不可编辑。
代码位于 Food.m 中 TextView内容位于Food.xib中
I am having a performance issue.
I have developed an app, I had no problems
with the navigation, the app was working smoothly.
Until I added the UITextView, when clicking
the button which switches the view to the view where
I used the TextView, it takes about 4 to 5 seconds to
switch the view. This happens when filling the textView
with about 30-40 lines of text.
I added the TextView using the interface builder, whiteout
adding any code related to UITextView in Xcode.
Can you please help me solving this issue ??
Thanks.
EDIT: This is the code for the page containing the TextView
// Food.m
// Azkar
//
// Created by al3madi on 18/02/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "Food.h"
#import "MainMenuViewController.h"
@implementation Food
- (IBAction) mainMenu:(id)sender {
MainMenuViewController* mainM = [[MainMenuViewController
alloc] initWithNibName:@"MainMenuViewController" bundle:nil];
[self.navigationController pushViewController:mainM animated:YES];
}
- (void)dealloc {
[MainMenuViewController release];
[super dealloc];
}
@end
NOTE: I have entered the text in the XIB file using the Interface Builder, not by coding, where I have changed the content of the TextView to the text I wanted. I also made the
TextView not editable.
The code is in Food.m
The TextView content is in Food.xib
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来有点奇怪。无论如何,请尝试以下操作。不要使用 Interface Builder 将文本放入
UITextView
中,而是以编程方式执行此操作。在负责处理UITextView
的视图控制器中,只需在viewDidLoad
方法中添加以下行:myTextView
是您分配给插座的名称与您的UITextView
关联的变量。This looks a bit weird. Anyway, try the following. Instead of putting the text in your
UITextView
using Interface Builder, do this programmatically. In the view controller responsible for handling yourUITextView
, simply add the following line in yourviewDidLoad
method:myTextView
is the name you assigned to the outlet variable associated to yourUITextView
.