如何检测按下的按钮并将其显示在另一个视图上?物镜 [英] How to detect the pressed button and display it on Another View? Objective-C

查看:60
本文介绍了如何检测按下的按钮并将其显示在另一个视图上?物镜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS应用开发的新手。我想在具有拆分视图的iOS中创建计算器应用程序。左侧是滚动视图中的历史记录功能,右侧是计算器本身。现在,关于此应用程序的历史记录功能,我认为我的程序需要识别已按下的内容,并在按下等于(=)按钮时将其显示在滚动视图中。您有什么想法在Objective-C上进行吗?我正在使用XCode 4.5和iPhone Simulator 6.0。

I am new to iOS app development. I want to create a Calculator App in iOS that has split view. The left side is the "History" Feature in Scroll View and the right side is the calculator itself. Now, regarding the History feature of this app, I am thinking that my program needs to recognize what has been pressed and display it on the Scroll View when the Equal (=) button is pressed. Do you have any idea how will this go on Objective-C? I am using XCode 4.5 and iPhone Simulator 6.0.

在此先感谢!

推荐答案

这是此要求的解决方案。

Here is the solution for this requirement.

在我的情况下。我在viewcontroller中有2个按钮。当我单击这些按钮时,我必须显示弹出窗口。为此,我必须检测在PopoverController(AnotherViewController)中单击了哪个按钮。

In my case.. I have 2 buttons in viewcontroller. When I click on those buttons I had to display popover. For this I had to detect which button is clicked in PopoverController(AnotherViewController).

首先,我采取了 @property BOOL isClicked; 在AppDelegate.h

First I have taken @property BOOL isClicked; in AppDelegate.h

和AppDelegate.m @synthesize isClicked; (将其合成)中

And in AppDelegate.m @synthesize isClicked; (synthesized it) and in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.

    isClicked = FALSE;
}

现在在ViewController.m中,对像这样更改的按钮实现了动作,

Now in ViewController.m where action is implemented for buttons changed like this,

- (IBAction)citiesButtonClicked:(id)sender
{
    AppDelegate *delegate = [UIApplication sharedApplication].delegate;
    delegate.isClicked = FALSE;
}

- (IBAction)categoryButtonClicked:(id)sender
{
    AppDelegate *delegate = [UIApplication sharedApplication].delegate;
    delegate.isClicked = TRUE;
}

-(void)viewDidLoad中的PopoverViewController(AnotherViewController) 方法

-(void)viewDidLoad {
{
    AppDelegate *delegate = [UIApplication sharedApplication].delegate;
    if (delegate.isClicked)
    {
        delegate.isClicked = FALSE;
        NSLog(@"popover clicked");
    }
    else
    {
        delegate.isClicked = TRUE;
        isClicked = YES;
    }
}

我希望它会有所帮助。让我知道您是否需要任何帮助。

I hope it helps. Let me know if you need any help.

这篇关于如何检测按下的按钮并将其显示在另一个视图上?物镜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆