我在做比较
- (CGFloat)tableView:(UITableView *)tblView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
当我检查一下时,我的应用程序的性能似乎真的变慢了 cell.detailTextLabel.text isEqualTo:@"None";
什么是比较和设置细胞高度的更好方法?
我有一个UITableView,当用户滚动时重新使用单元格.所有内容都会显示并滚动正常,除非用户单击实际行,突出显示的单元格会显示另一个单元格中的某些文本.我不确定为什么.
#define IMAGE_TAG 1111
#define LOGIN_TAG 2222
#define FULL_NAME_TAG 3333
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
STUser *mySTUser = [[[STUser alloc]init]autorelease];
mySTUser = [items objectAtIndex:indexPath.row];
AsyncImageView* asyncImage = nil;
UILabel* loginLabel = nil;
UILabel* fullNameLabel = nil;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
else {
asyncImage = (AsyncImageView *) [cell.contentView viewWithTag:IMAGE_TAG];
loginLabel = (UILabel …Run Code Online (Sandbox Code Playgroud) 我有一个包含一个NIB UINavigationController其中有一个UIViewController.在UIViewController正在从外部另一个笔尖加载.我无法设置视图属性,因此我收到错误:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "LBRootViewController" nib but the view outlet was not set.'
Run Code Online (Sandbox Code Playgroud)
如何正确设置我的视图属性?
iphone cocoa-touch objective-c interface-builder uinavigationcontroller
我有以下代码:
self.itemsCopy = [self.items mutableCopy];
//[self.itemsCopy addObjectsFromArray:self.items];
NSLog(@"------- BEFORE APPEND --------");
NSLog(@"items count: %d",[items count]);
NSLog(@"itemsCopy count: %d",[itemsCopy count]);
Run Code Online (Sandbox Code Playgroud)
我的结果是:
------- BEFORE APPEND --------
items count: 15
itemsCopy count: 15
Run Code Online (Sandbox Code Playgroud)
但是,如果我将第一行从mutableCopy更改为addObjectsFromArray:
[self.itemsCopy addObjectsFromArray:self.items];
Run Code Online (Sandbox Code Playgroud)
我的新结果是:
------- BEFORE APPEND --------
items count: 15
itemsCopy count: 0
Run Code Online (Sandbox Code Playgroud)
为什么mutableCopy会填充itemsCopy,但是addObjectsFromArray却没有?
- (void)viewDidLoad {
[super viewDidLoad];
//..do stuff..
}
Run Code Online (Sandbox Code Playgroud)
要么
- (void)viewDidLoad {
//do stuff
[super viewDidLoad];
Run Code Online (Sandbox Code Playgroud) @Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Selection Options");
menu.add(0, v.getId(), 0, "Remove");
}
Run Code Online (Sandbox Code Playgroud)
我希望我的菜单说"删除AAPL"
我会从我的数组适配器获取字符串AAPL,但我不知道如何从此方法访问我的数组适配器索引.
我想解析一些JSON:
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(e.Result)))
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(STMsgObj));
STMsgObj[] messages = (STMsgObj[])serializer.ReadObject(stream);
foreach(STMsgObj aMsg in messages){
MessageBox.Show(aMsg.body, "Data Passed", MessageBoxButton.OK);
}
}
}
Run Code Online (Sandbox Code Playgroud)
如何将e.Result转换为流?
例外:
System.InvalidCastException was unhandled
Message=InvalidCastException
StackTrace:
at StockTwits.ViewModels.StreamPage.webClient_DownloadStringCompleted(Object sender, DownloadStringCompletedEventArgs e)
at System.Net.WebClient.OnDownloadStringCompleted(DownloadStringCompletedEventArgs e)
at System.Net.WebClient.DownloadStringOperationCompleted(Object arg)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, …Run Code Online (Sandbox Code Playgroud) 我看过很多创建自定义标题栏的例子:http://zaman91.wordpress.com/2010/03/16/android-how-to-add-custom-title-bar/
有更简单的方法吗?我认为必须在onCreate()中为每个活动实现自定义标题栏代码有点过分.
我有一个带有两个ListView的垂直线性布局.我希望顶级ListView占据屏幕的50%.我希望底部的listivew占据屏幕的50%.我怎么能用XML做到这一点?
我有一个选项菜单,但不希望它在屏幕水平翻转时出现.我有以下方法来确定lanscape,但需要知道如何禁用选项菜单.
private boolean isLandscape() {
if (Configuration.ORIENTATION_LANDSCAPE == getResources().getConfiguration().orientation) {
return true;
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud) cocoa-touch ×5
objective-c ×5
android ×4
iphone ×4
java ×3
uitableview ×2
arrays ×1
c# ×1
cocoa ×1
contextmenu ×1
eclipse ×1
listadapter ×1
menu ×1
nsarray ×1
options-menu ×1
stream ×1
themes ×1
uiview ×1
xml ×1