ユーザーが正しく動作しているボタンを選択したときに別のビューコントローラに移動する水平スクロールボタンがありますが、ユーザーが戻るボタンをタップするとナビゲーションバーが非表示になります。ナビゲーションバーが水平スクロールビューでオーバーラップしています
横スクロールボタンがナビゲーションバーと重なっているようです。私はこれらのスクロールボタンをプログラムで記述しました。
ユーザーが正しく動作しているボタンを選択したときに別のビューコントローラに移動する水平スクロールボタンがありますが、ユーザーが戻るボタンをタップするとナビゲーションバーが非表示になります。ナビゲーションバーが水平スクロールビューでオーバーラップしています
横スクロールボタンがナビゲーションバーと重なっているようです。私はこれらのスクロールボタンをプログラムで記述しました。
戻るボタンの操作が正しく行われていない可能性があります。上にコメントしたように、私は本当に助けるためにもっとコードを見る必要があります。
HomeVC.h
#import <UIKit/UIKit.h>
@interface HomeVC :
UIViewController<UITableViewDelegate,UITableViewDataSource>
- (IBAction)buttonClicked1:(id)sender;
- (IBAction)buttonClicked2:(id)sender;
-(IBAction)unWindHomeVC:(UIStoryboardSegue *) segue;
-(void) imageTaped;
- (IBAction)myProflBtn:(id)sender;
- (IBAction)myContactBtn:(id)sender;
@property (strong, nonatomic) IBOutlet UITableView *tablezView1;
@property (strong, nonatomic) IBOutlet UITableView *tableView2;
@property (strong, nonatomic) NSArray *devices;
@end
HomeVC.m
#import "HomeVC.h"
#import "AddInfoVC.h"
#import "MyProfileTableViewCell.h"
#import "SuperObject.h"
#import "AppDelegate.h"
@interface HomeVC()
{
NSManagedObjectContext *context;
NSIndexPath *selectIndexPath;
}
@end
int j;
@implementation HomeVC
@synthesize tablezView1;
@synthesize tableView2;
@synthesize devices;
- (void)viewDidLoad
{
[super viewDidLoad];
AppDelegate *app = (AppDelegate *) [UIApplication
sharedApplication].delegate;
context = app.persistentContainer.viewContext;
}
-(void) viewWillAppear:(BOOL)animated {
NSMutableArray *arrImage = [NSMutableArray
arrayWithObjects:@"Recovery.png",
@"Fire.png",@"police.png",@"Hospital1.png",@"blood.png",nil];
UIScrollView *scrollView = [[UIScrollView alloc]
initWithFrame:CGRectMake(0,60, self.view.frame.size.width, 100)];
int x = 0;
CGRect frame;
for (int i = 0; i < 5; i++) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
if (i == 0) {
frame = CGRectMake(10, 25, 45, 45);
} else {
frame = CGRectMake((i * 80) + (i * 20) + 10, 25, 45, 45);
}
button.frame = frame;
button.tag=i;
NSString *butimage=arrImage[i];
UIImage *buttonImage = [UIImage imageNamed:butimage];
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
NSLog(@"%ld",(long)button.tag);
[button setBackgroundColor:[UIColor whiteColor]];
[button addTarget:self action:@selector(imageTapped:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:button];
if (i == 4)
{
x = CGRectGetMaxX(button.frame);
}
}
scrollView.contentSize = CGSizeMake(x, scrollView.frame.size.height);
scrollView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:scrollView];
}
-(void) viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSFetchRequest *fetch = [[NSFetchRequest alloc] initWithEntityName:@"Opositive"];
devices = [context executeFetchRequest:fetch error:nil];
[tablezView1 reloadData];
}
-(void)imageTapped:(id)sender
{
UIButton *button = (UIButton *) sender;
NSLog(@"tapped!");
NSLog(@"%ld",(long)button.tag);
switch(button.tag)
{
case 0 :
{
NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"RecoveryVC"];
[self presentViewController:vc animated:YES completion:nil];
}
break;
case 1 :{
NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"FireServiceVC"];
[self presentViewController:vc animated:YES completion:nil];
}
break;
case 2 :
{
NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"PoliceStationVC"];
[self presentViewController:vc animated:YES completion:nil];
}
break;
case 3 :
{
NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"HospitalVC"];
[self presentViewController:vc animated:YES completion:nil];
}break;
case 4 :
{
NSString * storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"BloodDonationVC"];
[self presentViewController:vc animated:YES completion:nil];
} break;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if(tableView == self.tablezView1){
return devices.count;
}
else if (tableView == self.tableView2){
return 5;
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == self.tablezView1){
static NSString *cellIdentifier1 = @"MyProfileTVCell";
MyProfileTableViewCell *cell1 = (MyProfileTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1];
if (cell1 == nil){
NSArray *nib1 =[[NSBundle mainBundle] loadNibNamed:@"MyProfileTableViewCell" owner:self options:nil];
cell1 = [nib1 objectAtIndex:0];
}
NSManagedObject *mangedObj = [devices objectAtIndex:indexPath.row];
cell1.prfNmeLbel.text = [NSString stringWithFormat:@"Profilename:%@",[mangedObj valueForKey:@"opositivename"]];
cell1.prfCntLbel.text = [NSString stringWithFormat:@"ProfileContactNo:%@", [mangedObj valueForKey:@"opositivecontactno"]];
cell1.prfCtyLbel.text = [NSString stringWithFormat:@"ProfileCity:%@", [mangedObj valueForKey:@"opositivecity"]];
cell1.prfAddresLbl.text = [NSString stringWithFormat:@"ProfileAddress:%@", [mangedObj valueForKey:@"opositivecaddress"]];
cell1.prfCountryLbl.text = [NSString stringWithFormat:@"ProfileCountry:%@", [mangedObj valueForKey:@"opositivecountry"]];
return cell1;
}
if (tableView == self.tableView2){
static NSString *cellIdentifier2 = @"CommonTVC";
CommonTVC *cell2 = (CommonTVC *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier2];
if (cell2 == nil){
NSArray *nib2 = [[NSBundle mainBundle] loadNibNamed:@"CommonTVC" owner:self options:nil];
cell2 = [nib2 objectAtIndex:0];
}
return cell2;
}
return 0;
}
-(BOOL) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row %2 == 0){
return YES;
}
return NO;
}
- (IBAction)addInfoButton:(id)sender {
AddInfoVC * DishItemList = [[UIStoryboard storyboardWithName:なし] instantiateViewControllerWithIdentifier: "メイン" バンドル@ @ "AddInfoVC"]; [self.navigationController pushViewController:DishItemList animated:YES]; }
- (IBAction)buttonClicked1:(id)sender {
UIStoryboard *storyboardObj = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
AddInfoVC *addInfoObj = [storyboardObj instantiateViewControllerWithIdentifier:@"AddInfoVC"];
[self presentViewController:addInfoObj animated:NO completion:nil];
}
(IBAction)buttonClicked2:(ID)、送信者{
UIStoryboard * storyboardObj = [UIStoryboard storyboardWithName: "メイン" バンドル@:なし]。
OptionVC * optObj = [storyboardObj instantiateViewControllerWithIdentifier:@ "OptionVC"];
[self presentViewController:optObj animated:NO completion:nil];ボタンが追加されている
}
- (IBAction)unWindHomeVC:(UIStoryboardSegue *)segue{
HomeVC *sourceVC = segue.sourceViewController;
if([sourceVC isKindOfClass:[AddInfoVC class]]){
NSLog(@"Coming from AddInfo");
}
if([sourceVC isKindOfClass:[ProfileVC class]]) {
NSLog(@"Coming from ProfileVC");
}
if ([sourceVC isKindOfClass:[MyContactsVC class]]){
NSLog(@"Coming from MyContacts");
}
}
- (IBAction)myProflBtn:(id)sender {
NSString *storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
ProfileVC *profile = [storyboard instantiateViewControllerWithIdentifier:@"ProfileVC"];
profile.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:profile animated:YES completion:nil];
// configure the popover presentation controller
UIPopoverPresentationController *popController = [profile popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionAny;
popController.delegate = self;
popController.sourceView = self.view;
popController.sourceRect = CGRectMake(30, 50, 10, 10);
}
- (IBAction)myContactBtn:(id)sender {
NSString *storyboardName = @"Main";
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
MyContactsVC *contact = [storyboard instantiateViewControllerWithIdentifier:@"MyContactsVC"];
contact.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:contact animated:YES completion:nil];
// configure the popover presentation controller
UIPopoverPresentationController *popController = [contact popoverPresentationController];
popController.permittedArrowDirections = UIPopoverArrowDirectionUp;
popController.delegate = self;
// In case we don't have a bar button as reference
popController.sourceView = self.view;
popController.sourceRect = CGRectMake(30, 50, 10, 10);
}
@end
?どのビューに –
詳細情報、関連コード、場合によってはスクリーンショットを提供する必要があります。あたかもあなたの問題が分からないかのように質問を読んでみてください。 – user5226582
@MartinBorstrand - ナビゲーションバーのすぐ下にあるホームVCにボタンが追加されます。水平にスクロールすることができます。 – Jonathan