Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 点击UICRollView按钮重新加载UICRollView_Ios_Objective C_Uiscrollview_Uibutton - Fatal编程技术网

Ios 点击UICRollView按钮重新加载UICRollView

Ios 点击UICRollView按钮重新加载UICRollView,ios,objective-c,uiscrollview,uibutton,Ios,Objective C,Uiscrollview,Uibutton,让我先解释一下我的项目。我在我的SQLIteDB表中有一些名为“note”的数据。 在“note”表中,我有以下字段:id,noteToken,note 我在这里做的是从该表中加载NSMUtableArray中的所有note。并根据该数组内容编号创建ui按钮,并将这些按钮作为子视图添加到ui视图中。按钮的数量和滚动视图的宽度根据该数组的内容数量自动生成。现在,当有人点击其中一个按钮时,它会将他带到下一个viewController,并向他显示该viewController中相应的注释详细信息 我

让我先解释一下我的项目。我在我的
SQLIte
DB表中有一些名为“note”的数据。 在“note”表中,我有以下字段:
id
noteToken
note

我在这里做的是从该表中加载
NSMUtableArray
中的所有
note
。并根据该
数组
内容编号创建
ui按钮
,并将这些按钮作为
子视图
添加到
ui视图中。按钮的数量和滚动视图的宽度根据该数组的内容数量自动生成。现在,当有人点击其中一个按钮时,它会将他带到下一个
viewController
,并向他显示该
viewController
中相应的注释详细信息

我对另一个
NSMUtableArray
做了同样的事情,但这一次它读取了“note”表中的所有
id
。它在相同的
UIScrollView
中同样生成新的删除按钮。但是如果有人点击这些删除按钮,它将从
SQLIte
DB的表“note”中删除特定的注释并重新加载
UIScrollView
。除了重新加载
UIScrollView
零件外,所有操作都已完成。这就是我想要的。我尝试了所有存在的解决方案,但不知道为什么它不起作用。
这是我的密码:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.noteToken = [NSString stringWithFormat:@"%@%@", fairId, exibitorId];

    scrollViewNoteWidth = 100;
    [scrollViewNote setScrollEnabled:YES];
    [scrollViewNote setContentSize:CGSizeMake((noteButtonWidth * countNoteButtonArray) + scrollViewNoteWidth, 100)];

    sqLite = [[SQLite alloc] init];
    [self.sqLite callDataBaseAndNoteTableMethods];

    self.noteButtonArrayy = [[NSMutableArray alloc] init];
    noteButtonArrayy = [self.sqLite returnDataFromNoteTable:noteToken];

    [self LoadNoteButtonAndDeleteButton:noteButtonArrayy];
}


//////////////*----------------------- Note Section (Down) -----------------------*//////////////
-(void) LoadNoteButtonAndDeleteButton:(NSMutableArray *) noteButtonArray
{
    sQLiteClass = [[SQLiteClass alloc] init];
    noteButtonArrayToShowNoteButton = [[NSMutableArray alloc] init];

    /*--------------- Load the noteButton & pass note (Down)---------------*/
    for (int i = 0; i < [noteButtonArray count]; i++)
    {
        sQLiteClass = [noteButtonArray objectAtIndex:i];
        // NSString *ids = [NSString stringWithFormat:@"%d", sQLiteClass.idNum];
        NSString *nt = sQLiteClass.note;
        [noteButtonArrayToShowNoteButton addObject:nt];
    }
    [self ShowNoteButtonMethod:noteButtonArrayToShowNoteButton];
    /*--------------- Load the noteButton & pass note (Up)---------------*/

    /*--------------- Load the deleteButton & pass id (Down)---------------*/
    noteButtonArrayToDeleteNoteButton = [[NSMutableArray alloc] init];
    for (int i = 0; i < [noteButtonArray count]; i++)
    {
        sQLiteClass = [noteButtonArray objectAtIndex:i];
        // Convert int into NSString
        NSString *ids = [NSString stringWithFormat:@"%d", sQLiteClass.idNum];
        [noteButtonArrayToDeleteNoteButton addObject:ids];
    }
    [self ShowNoteDeleteButtonMethod:noteButtonArrayToDeleteNoteButton];
    /*--------------- Load the deleteButton & pass id (Down)---------------*/
}

-(void) ShowNoteButtonMethod:(NSMutableArray *) btnarray
{
    countNoteButtonArray = [btnarray count];

    // For note button
    noteButtonWidth = 60;
    noteButtonXposition = 8;
    for (NSString *urls in btnarray)
    {
        noteButtonXposition = [self addNoteButton:noteButtonXposition AndURL:urls];
    }
}

-(int) addNoteButton:(int) xposition AndURL:(NSString *) urls
{
    noteButton =[ButtonClass buttonWithType:UIButtonTypeCustom];
    noteButton.frame = CGRectMake(noteButtonXposition, 8.0, noteButtonWidth, 60.0);
    [noteButton setImage:[UIImage imageNamed:@"note.png"] forState:UIControlStateNormal];
    [noteButton addTarget:self action:@selector(tapOnNoteButton:) forControlEvents:UIControlEventTouchUpInside];
    [noteButton setUrl:urls];
    noteButton.backgroundColor = [UIColor clearColor];
    [self.scrollViewNote addSubview:noteButton];
    noteButtonXposition = noteButtonXposition + noteButtonWidth + 18;

    return noteButtonXposition;
}

-(void)tapOnNoteButton:(ButtonClass*)sender
{
    urlNote = sender.url;
    [self performSegueWithIdentifier:@"goToNoteDetailsViewController" sender:urlNote];
}

-(void) ShowNoteDeleteButtonMethod:(NSMutableArray *) btnarray
{
    countNoteButtonArray = [btnarray count];

    // For delete button
    deleteNoteButtonWidth = 14;
    deleteNoteButtonXposition = 31;
    for (NSString *idNumber in btnarray)
    {
        deleteNoteButtonXposition = [self addDeleteButton:deleteNoteButtonXposition AndURL:idNumber];
    }
}

-(int) addDeleteButton:(int) xposition AndURL:(NSString *) idNumber
{
    deleteNoteButton =[ButtonClass buttonWithType:UIButtonTypeCustom];
    deleteNoteButton.frame = CGRectMake(deleteNoteButtonXposition, 74.0, deleteNoteButtonWidth, 20.0);
    [deleteNoteButton setImage:[UIImage imageNamed:@"delete.png"] forState:UIControlStateNormal];
    [deleteNoteButton addTarget:self action:@selector(tapOnDeleteButton:) forControlEvents:UIControlEventTouchUpInside];
    [deleteNoteButton setIdNum:idNumber];
    deleteNoteButton.backgroundColor = [UIColor clearColor];
    [self.scrollViewNote addSubview:deleteNoteButton];
    deleteNoteButtonXposition = deleteNoteButtonXposition + deleteNoteButtonWidth + 65;

    return deleteNoteButtonXposition;
}

-(void)tapOnDeleteButton:(ButtonClass*)sender
{
    idNumb = sender.idNum;
    [self.sqLite deleteData:[NSString stringWithFormat:@"DELETE FROM note WHERE id IS '%@'", idNumb]];
    // NSLog(@"idNumb %@", idNumb);

    //[self.view setNeedsDisplay];
    //[self.view setNeedsLayout];
    //[self LoadNoteButtonAndDeleteButton];
    //[self viewDidLoad];

//    if ([self isViewLoaded])
//    {
//        //self.view = Nil;
//        //[self viewDidLoad];
//        [self LoadNoteButtonAndDeleteButton];
//    }
}
//////////////*----------------------- Note Section (Up) -----------------------*//////////////

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"goToNoteDetailsViewController"])
    {
        NoteDetailsViewController *noteDetailsViewController = [segue destinationViewController];
        [noteDetailsViewController setUrl:sender];
    }
}
-(void)viewDidLoad
{
[超级视图下载];
self.noteToken=[NSString stringWithFormat:@“%@%@”,fairId,exibitorId];
scrollViewNoteWidth=100;
[scrollViewNote SetScrolEnabled:是];
[ScrollViewNoteSetContentSize:CGSizeMake((noteButtonWidth*countNoteButtonArray)+scrollViewNoteWidth,100)];
sqLite=[[sqLite alloc]init];
[self.sqLite callDataBaseAndNoteTableMethods];
self.notebuttonaray=[[NSMutableArray alloc]init];
NoteButtonArray=[self.sqLite returnDataFromNoteTable:noteToken];
[自加载NoteButton和DeleteButton:NoteButtonArray];
}
//////////////*-----------------------注释部分(向下)-----------------------*//////////////
-(void)LoadNoteButton和DeleteButton:(NSMutableArray*)noteButtonArray
{
sQLiteClass=[[sQLiteClass alloc]init];
NoteButtonArray ToShownoteButton=[[NSMutableArray alloc]init];
/*---------------加载注释按钮并传递注释(向下)---------------*/
对于(int i=0;i<[noteButtonArray count];i++)
{
sQLiteClass=[noteButtonArray对象索引:i];
//NSString*ids=[NSString stringWithFormat:@“%d”,sQLiteClass.idNum];
NSString*nt=sQLiteClass.note;
[noteButtonarraytownotebuttonaddobject:nt];
}
[自显示NoteButton方法:NoteButtonRayToShownNoteButton];
/*---------------加载备忘按钮并传递备忘(向上)---------------*/
/*---------------加载deleteButton和pass id(向下)---------------*/
NoteButtonArrayToDeleteButton=[[NSMutableArray alloc]init];
对于(int i=0;i<[noteButtonArray count];i++)
{
sQLiteClass=[noteButtonArray对象索引:i];
//将int转换为NSString
NSString*ids=[NSString stringWithFormat:@“%d”,sQLiteClass.idNum];
[notebuttonarraytodelenotebutton addObject:ids];
}
[自显示NoteDeleteButton方法:NoteButtonRayToDeleteButton];
/*---------------加载deleteButton和pass id(向下)---------------*/
}
-(void)ShowNoteButtonMethod:(NSMutableArray*)btnarray
{
countNoteButtonArray=[btnarray计数];
//备忘按钮
noteButtonWidth=60;
noteButtonXposition=8;
for(btnarray中的NSString*URL)
{
noteButtonXposition=[self-addNoteButton:noteButtonXposition和URL:URL];
}
}
-(int)addNoteButton:(int)xposition和url:(NSString*)URL
{
noteButton=[ButtonClassButtonWithType:UIButtonTypeCustom]的按钮类按钮;
noteButton.frame=CGRectMake(noteButtonXposition,8.0,noteButtonWidth,60.0);
[noteButton setImage:[UIImage ImageName:@“note.png”]用于状态:UIControlStateNormal];
[noteButton addTarget:self action:@selector(tapOnNoteButton:)for ControlEvents:UIControlEventTouchUpInside];
[noteButton setUrl:URL];
noteButton.backgroundColor=[UIColor clearColor];
[self.scrollview注释添加子视图:注释按钮];
noteButtonXposition=noteButtonXposition+noteButtonWidth+18;
返回按钮位置;
}
-(无效)点击NoteButton:(按钮类*)发送者
{
urlNote=sender.url;
[self-PerformsgueWithIdentifier:@“goToNoteDetailsViewController”发件人:urlNote];
}
-(void)ShowNoteDeleteButtonMethod:(NSMutableArray*)btnarray
{
countNoteButtonArray=[btnarray计数];
//用于删除按钮
deleteNoteButtonWidth=14;
deleteNoteButtonXposition=31;
用于(NSString*btnarray中的idNumber)
{
deleteNoteButtonXposition=[self-addDeleteButton:deleteNoteButtonXposition和URL:idNumber];
}
}
-(int)addDeleteButton:(int)xposition和url:(NSString*)idNumber
{
deleteNoteButton=[ButtonClassButtonWithType:UIButtonTypeCustom]的按钮类按钮;
deleteNoteButton.frame=CGRectMake(deleteNoteButtonXposition,74.0,deleteNoteButtonWidth,20.0);
[deleteNoteButton setImage:[UIImage ImageName:@“delete.png”]用于状态:UIControlStateNormal];
[deleteNoteButton addTarget:self action:@selector(tapOnDeleteButton:)for ControlEvents:UIControlEventTouchUpInside];
[deleteNoteButton setIdNum:idNumber];
deleteNoteButton.backgroundColor=[UIColor clearColor];
[self.scrollViewNote addSubview:deleteNoteButton];
deleteNoteButtonXposition=deleteNoteButtonXposition+deleteNoteButtonWidth+65;
返回deleteNoteButtonXposition;
}
-(无效)点击删除按钮:(按钮类*)发送器
{
idNumb=sender.idNum;
[self.sqLite deleteData:[NSString stringWithFormat:@“从id为“%@”的便笺中删除,idNumb];
//NSLog(@“idNumb%@”,idNumb);
//[self.view setNeedsDisplay];
//[self.view setNeedsLayout];
//[自动加载NoteButton和DeleteButton