对于我正在开发的应用程序,我需要检查文本字段是否仅包含字母 A、T、C 或 G。此外,我想为任何其他输入的字符制作专门的错误消息。例如)“不要输入空格。” 或“字母 b 不是可接受的值。” 我读过其他几篇类似的文章,但它们是字母数字,我只想要指定的字符。
如何让应用程序在点击25个单元格后停止从阵列创建单元格?就目前而言,数组"cellArray"包含超过25个元素,并且没有代码可以阻止程序生成单元格.
CollectionViewContoller.m:
@implementation CollectionViewController
//Delegate Methods
-(NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.cellArray.count;
}
-(UICollectionViewCell*) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
Cell * aCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"bingoCell1" forIndexPath:indexPath];
aCell.cellContent.text = self.cellArray[indexPath.row];
return aCell;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.cellArray =
@[@"Type 1", @"Type …Run Code Online (Sandbox Code Playgroud) 我有一个按钮,当我选择3个分段控件时,我想执行不同的代码.EX)如果选择了segment1,按下按钮时将执行Code1.如果选择了segment2,则在按下按钮时将执行Code2.我之前没有使用过Segmented Controls,有谁知道怎么做?
我正在为一个朋友做一个小项目.我最近在Codecademy上学习了jQuery,这是我第一次将它整合到一个网页中.但是,它不起作用,我不知道为什么.此外,如果有人可以指导我如何使文本框居中,等等,看起来像下面链接的图像,请告诉我.

这是我的index.html:
<!DOCTYPE html>
<html>
<head>
<title>DNA Translator</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script> type="text/javascript" src="script.js"</script>
<script></script>
</head>
<body>
<div id="content">
<form>
DNA: <input type="text" name="dna" placeholder="DNA"><br>
mRNA: <input type="text" name="mrna" placeholder="mRNA"><br>
tRNA: <input type="text" name="trna" placeholder="tRNA"<br>
Amino Acids: <input type="text" name="aminoAcids" placeholder="Amino Acids"<br>
</form>
<button id="button" type="button">Tanslate</button>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的stylesheet.css:
h2 {
font-family:arial;
}
form {
display: inline-block;
}
#content {
margin-top: 200px;
margin-left: auto;
margin-right: auto;
}
#button{
opacity: 0.7;
display: inline-block;
height:25px;
width:300px;
background-color:#293FE3; …Run Code Online (Sandbox Code Playgroud)