我有两个信息数组,我通过以下内容加载到UITableView控件:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
if(indexPath.section == 0)
cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];
else
cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
我想要在其下面的顶部数组(arryTableData)作为第一个单元格的位置图像.
arryTableData = [[NSArray alloc] initWithObjects:[NSString stringWithFormat:@"%@", locName],
[NSString stringWithFormat:@"%@", locPhone],
@"Address Info",
@"Access Icons",
nil];
Run Code Online (Sandbox Code Playgroud)
所以就在locName之前我希望locImage在那里.如何将图像加载到数组中,然后将其显示在单元格中?
谢谢
汤姆
我正在通过简单的方式将图像加载到UITableView中
cell.imageView.image = [UIImage imageNamed:@"prem.jpg"];
Run Code Online (Sandbox Code Playgroud)
但是,我在有限的时间内从xcode中学到的东西通常都不容易!我想让图像在那里占据大约280宽和150高的图像的全尺寸.从谷歌搜索我可能要建立一个自定义单元格并将图像放在那里,然后加载该自定义单元格?我之前没有做过这样的事情,加载一张图片似乎有点烦人.还有其他选择吗?
为了放置上下文,我在tableview顶部有3个部分是图像,另外两个是从XML文件加载的数组.如果我做一个自定义单元格,我必须进行单独的xml调用才能获取图像URL,所以我真的想避免这种情况吗?
真的在寻找你能提供的任何指针.非常感谢
汤姆
编辑:cellforrowindexpath为requsted:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
if(indexPath.section == 0)
cell.imageView.image = [UIImage imageNamed:@"prem.jpg"];
if(indexPath.section == 1)
cell.textLabel.text = [arryTableData objectAtIndex:indexPath.row];
else if(indexPath.section == 2)
cell.textLabel.text = [arryTableActions objectAtIndex:indexPath.row];
return cell;
}
Run Code Online (Sandbox Code Playgroud) 我对某些东西感到困惑.我正在尝试创建一个自定义单元格,我想使用界面生成器方式.
我创建表的正常方法是将表作为:
.H
@interface AssessList : UIViewController {
IBOutlet UITableView *tblAssessList;
}
@property(nonatomic, retain) UITableView *tblAssessList;
@end
Run Code Online (Sandbox Code Playgroud)
.M
- (NSInteger)
numberOfSectionsInTableView:(UITableView *)tableView {
return groupArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return totalArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"I am the text....";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
现在我已经为单元格创建了一个新类,我想我知道如何将它放入.但是我可以将.h保留为
@interface AssessList : UIViewController
Run Code Online (Sandbox Code Playgroud)
或者带有完整表的类/ nib是否 …
我知道我在这里是个白痴,我无法解决这个问题.但我正试图从vb.net数据库中取回一些数据.它没有被设置为对象错误的实例,它正在倒下.在代码运行之前,它表示变量在设置之前正在使用,但我看不清楚如何.码:
Private taNotifications As dsDataTableAdapters.NotificationsTableAdapter = New dsDataTableAdapters.NotificationsTableAdapter
Dim notification As dsData.NotificationsDataTable = taNotifications.GetDataByClientID(userrow.UserID)
If notification.Rows.Count > 0 Then
Dim notificationrow As dsData.NotificationsRow
Dim forwardURL As String = notificationrow.ForwardLocation
End If
Run Code Online (Sandbox Code Playgroud)
它落在了 Dim forwardURL As String = notificationrow.ForwardLocation
我有一个看起来像下面的布局.但理想情况下,我希望按钮"保存"和"取消"各自为50%宽度,彼此相邻.虽然看起来不太可能让他们工作.
有什么建议?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<Button
android:id="@+id/btnMinus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="-" />
<EditText
android:id="@+id/txtCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btnPlus"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/btnPlus"
android:layout_toRightOf="@+id/btnMinus"
android:ems="10"
android:inputType="number" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btnPlus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="+" />
<Button
android:id="@+id/btnGo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btnMinus"
android:layout_toRightOf="@+id/button1"
android:maxWidth="100dp"
android:text="Save"
android:width="100dp" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/btnMinus"
android:text="Cancel" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) 我正在尝试做一个简单的数学picee,如果一个值在两个值之间,我会计算出来,如果是这样,那么它应该做一个简单的除法.然而,有时候除以的值是0.9,0.6等,并且总是返回0.
在这个例子中,
int m_LocationSqrMtr = 4339;
float m_DefaultPricing = Convert.ToSingle(DefaultPricing);
float m_manDays;
if (m_LocationCosts > 450 && m_LocationCosts < 700)
{
m_DefaultPricing = 700 / m_LocationSqrMtr;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用以下内容来获取现在的时间/日期为sql insert的一个很好的格式.日期工作正常,但时间总是返回0:0:0.
public static String getDateString()
{
DateTime time = DateTime.Now;
String sqlFormattedDate = time.Date.ToString("yyyy-MM-dd HH:mm:ss");
return sqlFormattedDate;
}
Run Code Online (Sandbox Code Playgroud) ios ×3
iphone ×3
xcode ×3
asp.net ×2
c# ×2
android ×1
java ×1
layout ×1
math ×1
objective-c ×1
sql ×1
sql-server ×1
uiimageview ×1
uitableview ×1
vb.net ×1