내 응용 프로그램에서 tableview 데, 행을 클릭하면 뷰를 열 때 두 개의 이미지가 데이터베이스에서 서로 다른 두 테이블을 형성하는 두 개의 이미지 viwer를 포함하므로 하나의 이미지 뷰어가 이미지에 표시됩니다. 두 번째와 같이 모두에 대해 동일한 이미지 내 코드, 데이터베이스에서클릭 할 때 다른 이미지 Uitableview 행
이첫 번째 이미지, 데이터베이스에서
-(void)Readthesqlitefileforname:(NSString *)brandname
{
sqlite3 *database;//database object
NSString *docpath=[self doccumentspath];
const char *ch=[docpath UTF8String];//string to constant char UTF8string main part to connect DB
if (sqlite3_open(ch, &database)==SQLITE_OK)
{
NSString *strstmt=[NSString stringWithFormat:@"select name,nik,dob,study,phone,mail,fsong,dp from scrap where name = '%@'",brandname];
const char *chstmt=[strstmt UTF8String];
sqlite3_stmt *sqlstmt;//to execute the above statement
if (sqlite3_prepare_v2(database, chstmt, -1, &sqlstmt, NULL)==SQLITE_OK)
{
while (sqlite3_step(sqlstmt)==SQLITE_ROW) {
const char *ch=(char *)sqlite3_column_text(sqlstmt, 0);
bnnam=[NSString stringWithFormat:@"%s",ch];
const char *ch1=(char *)sqlite3_column_text(sqlstmt, 1);
urladdr=[NSString stringWithFormat:@"%s",ch1];
const char *ch2=(char *)sqlite3_column_text(sqlstmt, 2);
ydob=[NSString stringWithFormat:@"%s",ch2];
const char *ch3=(char *)sqlite3_column_text(sqlstmt, 3);
ystud=[NSString stringWithFormat:@"%s",ch3];
const char *ch4=(char *)sqlite3_column_text(sqlstmt, 4);
yphon=[NSString stringWithFormat:@"%s",ch4];
const char *ch5=(char *)sqlite3_column_text(sqlstmt, 5);
ymail=[NSString stringWithFormat:@"%s",ch5];
const char *ch6=(char *)sqlite3_column_text(sqlstmt,6);
yface=[NSString stringWithFormat:@"%s",ch6]; //NSLog(@"%@",urladdr);
//const char *ch5=(char *)sqlite3_column_text(sqlstmt, 4);
NSUInteger legnth=sqlite3_column_bytes(sqlstmt, 7);
if (legnth>0)
{
NSData *dt=[NSData dataWithBytes:sqlite3_column_blob(sqlstmt, 7) length:legnth];
clsimg=[UIImage imageWithData:dt];//converting data to image
NSLog(@"image 1 %@",clsimg);
}
else
{
clsimg=nil;
}
}
}
sqlite3_finalize(sqlstmt);
}
sqlite3_close(database);
}
두 번째 이미지를 rows.Here 어디 행은 클릭
-(void)Readsqlitefile
{
sqlite3 *database;//database object
NSString *docpath=[self doccumentspath];//get sqlite path
const char *ch=[docpath UTF8String];
if (sqlite3_open(ch, &database)==SQLITE_OK)
{
const char *chstmt="select * from scrapsign";
sqlite3_stmt *sqlstmt;
if (sqlite3_prepare_v2(database, chstmt, -1, &sqlstmt, NULL)==SQLITE_OK)
{
while (sqlite3_step(sqlstmt)==SQLITE_ROW)
{
NSUInteger legnt=sqlite3_column_bytes(sqlstmt, 0);
if (legnt>0) {
NSData *dt=[NSData dataWithBytes:sqlite3_column_blob(sqlstmt, 0) length:legnt];
mysign=[UIImage imageWithData:dt];
}
else
{
mysign=nil;
}
}
}
sqlite3_finalize(sqlstmt);
}
sqlite3_close(database);
}
두 이미지 뷰어에 다른 이미지를 표시해야합니다 행을보기를 클릭하는 동안 행
이미지 설정은
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
scrapview *detailViewController = [[scrapview alloc] initWithNibName:@"scrapview" bundle:nil];
[self Readthesqlitefileforname:[ar objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:detailViewController animated:YES];
if (clsimg !=nil)
{
detailViewController.imgv.image=clsimg;
}
[self Readsqlitefile];
if (mysign !=nil)
{
detailViewController.imgv2.image=mysign;//second image viewer
NSLog(@"%@",mysign);
}
detailViewController.txt1.text=urladdr;
detailViewController.txt2.text=ydob;
detailViewController.txt3.text=ystud;
detailViewController.txt4.text=yphon;
detailViewController.txt5.text=ymail;
detailViewController.txt.text=yface;
detailViewController.txt7.text=bnnam;
}
을 클릭,하지만 하나 개의 이미지 만보기에만 모든 행 클릭 수, 클릭에 두 번째 보여주는 동일한 이미지를 변경합니다. 문제를 해결할 수 있도록 도와주세요.
무엇이 문제입니까? – TheTiger
예, 무엇이 문제입니까?)) – Stas
행을 클릭하면 뷰가 두 이미지 뷰어에서 서로 다른 이미지를 보여야하지만 하나의 이미지보기 만 클릭 할 때만 변경됩니다. 두 번째 이미지는 모든 행 클릭에 대해 동일한 이미지를 표시합니다. @VakulSaini – iosdev