Tag: uibutton

input拖动时突出显示button

刚开始探索iOS SDK。 我有一些button,需要突出显示他们触摸外面一次,然后拖动。 据我所知,TouchDragEnter事件触发,当你点击button,然后拖到外面再次拖动里面。 点击button外部时,是否有任何事件触发,然后拖入内部?

如何调整UIButton中的文本的字体大小,以在Swift中以编程方式适应宽度?

我正在尝试以编程方式在我的UIButton设置文本,但是在button中显示时,文本会变成缩写。 有没有办法通过代码来调整button中文字的字体大小以适应宽度? 我已经检查了其他问题,但答案并不能解决我的问题。 谢谢。

如何以编程方式创build的uibutton以编程方式显示popover(不使用界面生成器)

我有一个button,我已经在视图控制器内编程创build。 一旦button被按下,我希望它使用一种方法来编程创buildpopover。 在我的视图controller.m中的ViewDidLoad中创build的button UIView *moreFundInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 540, 620)]; [self.view addSubview:moreFundInfoView]; [moreFundInfoView setBackgroundColor:[UIColor RMBColor:@"b"]]; btnContact = [UIButton buttonWithType:(UIButtonTypeRoundedRect)]; [btnContact setFrame:CGRectMake(390, 575, contactButton.width, contactButton.height)]; btnContact.hidden = NO; [btnContact setTitle:@"Contact" forState:(UIControlStateNormal)]; [moreFundInfoView addSubview:btnContact]; [btnContact addTarget:self action:@selector(showContactDetails:) forControlEvents:UIControlEventTouchUpInside]; 然后我有我按下button时使用的方法。 -(void) showContactDetails: (id) sender { UIViewController *popoverContent = [[UIViewController alloc]init]; UIView *popoverView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, […]

从Swift中的UITableViewCell子类中获取IndexPath

我有一个自定义的UITableViewCell子类及其关联的xib。 我在这个单元格中有一个UILabel和一个UIButton ,我已经把button的内部动作连接到子类。 我需要的是当单元格中的button被点击时,获取具有该button的单元格的索引path。 也许可以通过代理或其他东西发回给视图控制器。 由于我在UITableViewCell子类中,所以我不能使用这样的解决scheme,因为我没有从单元格子类内引用tableview。 经过进一步的调查,我发现了另一个解决scheme,我在这样的Swift中实现。 import UIKit class ContactCell: UITableViewCell { @IBOutlet weak var nameLabel: UILabel! override func awakeFromNib() { super.awakeFromNib() // Initialization code selectionStyle = .None } @IBAction func callButtonPressed(sender: UIButton) { let indexPath = (self.superview as UITableView).indexPathForCell(self) println("indexPath?.row") } } 但是,当我点击button,它崩溃了一个错误消息说Swiftdynamic投射失败 。 任何想法我的代码有什么问题? 或者我愿意接受任何其他的build议,以便让我以任何其他方式达到预期的结果。 谢谢。

UIImageView识别器

在我的应用程序,我有一个大UIImageView和其他5个较小。 我的意图是将选定的小图像的内容复制到最大的一个。 也获取所选图像的名称并用UILabel显示。 将UButtons更换为小图像可能更容易,并显示图像作为背景?

每个单元格的单独button,创build为find的设备

我试图做一个自定义的单元格,当它发现设备时生成原型单元格,这意味着每个设备都有一行。 每个button都必须在自己的设备上运行。 自定义单元格: 我创build了一个UITableViewCell并声明了标签,button和图像。 我有麻烦,使button作为个人button在TableViewController.Here是TableViewController.m – (interruptorTableCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"dimmableCell"; interruptorTableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; BinaryLight1Device *dispositivoApresentadoNaTabRetiradoDaListaDeFiltrados = [self.model.devicesFiltrados objectAtIndex:indexPath.row]; cell.accessoryView = cell.ligaDeslBtnPro; cell.ligaDeslBtnPro.tag = indexPath.row; [cell.ligaDeslBtnPro addTarget:self action:@selector(ligaDeslBtn:) forControlEvents:UIControlEventTouchUpInside]; cell.dimmableLabel.text = [dispositivoApresentadoNaTabRetiradoDaListaDeFiltrados friendlyName]; return cell; } 这是在TableView Cell中声明的button操作: – (IBAction)ligaDeslBtn:(UIButton *)sender { interruptorTableCell *cell = (interruptorTableCell*)[sender […]

如何在UINavigation Bar中添加dynamic/多重button?

如何在UINavigatation Bar中添加dynamic/多重button? 像下图:

UIButton说

我正在做多个自定义button,看起来像这样: 这是一个简单的button,在“指示器视图”中显示绿色或灰色。 我需要一些解释是:在interfacebuilder中有一个button可以有四个状态; 正常,突出显示,选中和禁用。 当我提供除残疾人以外的所有图片时,我认为正常的情况是在button上没有任何触摸,突出显示的是当你按住手指时,select的是当你松开手指后。 不过我现在不这么认为。 我使用touch-up-inside事件。 是否正确,我需要设置button上的选定/突出显示等属性? 感谢您的时间。

button打开新的视图

我最近成为一名成员,因为我注意到这里有很多的知识,我是一个完整的iOS应用程序的初学者。 我目前正在制作一个完美的应用程序,可以完成我想要的任何事情。 唯一的问题是我添加了一个新的button到应用程序,我不知道如何打开一个新的视图,或者如何将它连接到一个segue或任何将打开新的视图。 我编程的button,作为一个select器,我有一个名为pushnext的方法。 我想实现一个方法,将打开一个视图,但我所知道的是,我想要显示在视图中的信息包含在GridViewController.m,我不知道如何调用该视图,我已经读了很多其他职位在这里,但我似乎无法弄清楚。 我希望你们能帮助我。 感谢您的时间。 我也使用了以下的故事板: 标签栏控制器(2个图标):然后从那里分成第一个视图控制器,然后到导航控制器。 从导航控制器连接到网格视图控制器(我想要button打开),然后从网格视图控制器它有一个连接到详细视图连接。 如果可以的话,请帮助我。 我遵循在这里find的指南,如果它可以帮助你http://mobile.tutsplus.com/tutorials/iphone/design-build-a-small-business-app-custom-detail-views/ 编辑:我已经添加了我下面的代码,所以这对你们更容易。 我现在终于看到了,原因是因为我使用的是“添加评论”而不是回答问题。 这是我在FirstViewController.h中的 -(void)pushnext; 然后我在FirstViewController.m中有我的button self.roundButton = [self createButtonWithPicture:CGRectMake(110, 200, 100, 100) andLabel:@""]; [self.view addSubview:roundButton]; [self.roundButton addTarget:self action:@selector(pushnext:) forControlEvents:UIControlEventTouchUpInside]; FirstViewController.m里面我有我想要用我的button打开新视图的实现: -(void)pushnext{ [UIView transitionFromView:contact toView:cable duration:1.0 options UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished){ [contact release]; }]; 从那里我想方法pushnext打开我的看法,但我似乎无法得到它。 我有我的button设置在应用程序加载后popup的第一个屏幕,我不知道是什么视图被称为所以我打电话给我的代码联系,我希望它打开所有的视图GridViewController.m包含的信息我只是不知道该怎么做。 你build议使用一个segue来连接它们,但我应该如何将一个segue连接到我的button。 我也有问题,我的button是不是通过IB编程完成的。 谢谢你的时间,我希望你能帮助我。 再次感谢你,我只是绝望,因为我一直被困在试图通过阅读和例子来解决的日子,我只是不明白。 我还附上了我的故事板的图片。 在那里你可能会看到更好的我在说什么,我有我的button编程在“标签栏控制器”页面,但我希望button来打开标签“网格视图控制器秒”的网页,图像在这里HTTP ://i.stack.imgur.com/YKs1o.png

UIButton:当isHighlighted = true时,我只能通过滑动手指来调用一个函数

需要你的一些伟大的知识:) 我写了一个UIButton( CustomWideButton.swift )的子类而不使用UIButton对象。 我这样做是因为它对于我需要创build的buttontypes更加灵活。 有一个奇怪的事情,我不知道这是否是一个正常的行为。 当点击正常的button区域时调用var isHighlighted 。 所以如果我写这样的东西: var isHighlighted { didSet { print("I am Highlighted") animateHighlight() } } 我将在控制台中看到“我突出显示”,但是它不会调用animateHighlight(),除非我稍微开始在button上滑动手指。 如果我这样做,那么animateHighlight()的作品。 我在BitBucket上发布了一个示例项目,这样你会更容易理解我面临的问题: https : //bitbucket.org/stephaneDepoilly/stackohighlightedbutton 直接链接为zip: https : //bitbucket.org/stephaneDepoilly/stackohighlightedbutton/get/ee4fc398f475.zip 我很抱歉,如果自定义button代码看起来过度,这是因为我从我的项目中部分提取它,我们正在使用MVVM。 在此先感谢您的帮助!